[−][src]Trait bookbinder_ast::ContributorSource
Implemented for str-like types which can be interpreted as either a single name or multiple names; this is a convenience trait to allow overloading methods to add names rather than having to have a method to add a single name and one to add multiple names. It shouldn't really be a worry for end users, since it is pre-implemented for likely types.
let single_name = "Name One"; let multiple_names = vec!["Name One, Name Two"]; assert!(single_name.is_single_name()); assert_eq!(multiple_names.is_single_name(), false); assert_eq!(single_name.to_vec(), vec!["Name One"]); assert_eq!(multiple_names.clone().to_vec(), multiple_names.clone()); assert_eq!(single_name.to_single(), Some(Cow::Borrowed("Name One"))); assert_eq!(multiple_names.to_single(), None);
Required methods
Loading content...Provided methods
fn is_single_name(&self) -> bool
does this represent only a single name?
fn to_single(self) -> Option<Cow<'a, str>>
get a single name if this represented only a single name