Write missing documentation in iced_native

This commit is contained in:
Héctor Ramón Jiménez 2022-08-05 05:15:41 +02:00
parent 13dd1ca0a8
commit 66f7d43dc9
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
8 changed files with 81 additions and 2 deletions

View file

@ -3,14 +3,19 @@ use std::sync::atomic::{self, AtomicUsize};
static NEXT_ID: AtomicUsize = AtomicUsize::new(0);
/// The identifier of a generic widget.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Id(Internal);
impl Id {
/// Creates a custom [`Id`].
pub fn new(id: impl Into<borrow::Cow<'static, str>>) -> Self {
Self(Internal::Custom(id.into()))
}
/// Creates a unique [`Id`].
///
/// This function produces a different [`Id`] every time it is called.
pub fn unique() -> Self {
let id = NEXT_ID.fetch_add(1, atomic::Ordering::Relaxed);