pub enum Id<'a> {
Name(Cow<'a, str>),
Author(Cow<'a, str>),
NameAndAuthor {
name: Cow<'a, str>,
author: Cow<'a, str>,
},
}Expand description
Variants§
Implementations§
Source§impl Id<'_>
impl Id<'_>
Sourcepub fn updated(self, new: Self) -> Self
pub fn updated(self, new: Self) -> Self
Returns a new Id that is updated with values of the new parameter.
§Examples
let mut id = Id::Name("Carp".into());
id = id.updated(Id::Name("Salmon".into()));
assert_eq!(id, Id::Name("Salmon".into()));
id = id.updated(Id::Author("Fischerman".into()));
assert_eq!(
id,
Id::NameAndAuthor {
name: "Salmon".into(),
author: "Fischerman".into()
}
);
id = id.updated(Id::Author("Garry Chess".into()));
assert_eq!(
id,
Id::NameAndAuthor {
name: "Salmon".into(),
author: "Garry Chess".into()
}
);
id = id.updated(Id::Name("Big Tuna".into()));
assert_eq!(
id,
Id::NameAndAuthor {
name: "Big Tuna".into(),
author: "Garry Chess".into()
}
);Trait Implementations§
Source§impl<'de, 'a> Deserialize<'de> for Id<'a>
impl<'de, 'a> Deserialize<'de> for Id<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<'a> Eq for Id<'a>
impl Message for &Id<'_>
impl Message for &Id<'_>
impl Message for Id<'_>
impl Message for Id<'_>
impl<'a> StructuralPartialEq for Id<'a>
Auto Trait Implementations§
impl<'a> Freeze for Id<'a>
impl<'a> RefUnwindSafe for Id<'a>
impl<'a> Send for Id<'a>
impl<'a> Sync for Id<'a>
impl<'a> Unpin for Id<'a>
impl<'a> UnwindSafe for Id<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more