pub struct Name(/* private fields */);Expand description
String slice for Name.
Implementations§
Source§impl Name
impl Name
Sourcepub unsafe fn new_unchecked(s: &str) -> &Self
pub unsafe fn new_unchecked(s: &str) -> &Self
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the string as &str.
§Examples
let name = Name::from_str("hello")?;
assert_eq!(name, "hello");
let s: &str = name.as_str();
assert_eq!(s, "hello");Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of the string in bytes.
§Examples
let name = Name::from_str("foo:bar")?;
assert_eq!(name.len(), 7);Sourcepub fn parse_next(s: &str) -> Result<(&Self, &str), NameError>
pub fn parse_next(s: &str) -> Result<(&Self, &str), NameError>
Parses the leading Name and returns the value and the rest input.
§Exmaples
let input = "hello, world";
let expected = Name::from_str("hello").expect("valid Name");
assert_eq!(
Name::parse_next(input),
Ok((expected, ", world"))
);let input = "012";
assert!(Name::parse_next(input).is_err());Sourcepub fn into_boxed_str(self: Box<Self>) -> Box<str>
pub fn into_boxed_str(self: Box<Self>) -> Box<str>
Converts a Box<Name> into a Box<str> without copying or allocating.
§Examples
let name = Name::from_str("name")?;
let boxed_name: Box<Name> = name.into();
assert_eq!(&*boxed_name, name);
let boxed_str: Box<str> = boxed_name.into_boxed_str();
assert_eq!(&*boxed_str, name.as_str());Trait Implementations§
Source§impl PartialOrd<&Name> for str
impl PartialOrd<&Name> for str
Source§impl PartialOrd<&String> for Name
impl PartialOrd<&String> for Name
Source§impl PartialOrd<&str> for Name
impl PartialOrd<&str> for Name
Source§impl PartialOrd<Box<str>> for Name
impl PartialOrd<Box<str>> for Name
Source§impl PartialOrd<Cow<'_, str>> for Name
impl PartialOrd<Cow<'_, str>> for Name
Source§impl PartialOrd<Name> for &String
impl PartialOrd<Name> for &String
Source§impl PartialOrd<Name> for &str
impl PartialOrd<Name> for &str
Source§impl PartialOrd<Name> for Box<str>
impl PartialOrd<Name> for Box<str>
Source§impl PartialOrd<Name> for Cow<'_, str>
impl PartialOrd<Name> for Cow<'_, str>
Source§impl PartialOrd<Name> for String
impl PartialOrd<Name> for String
Source§impl PartialOrd<Name> for str
impl PartialOrd<Name> for str
Source§impl PartialOrd<String> for Name
impl PartialOrd<String> for Name
Source§impl PartialOrd<str> for &Name
impl PartialOrd<str> for &Name
Source§impl PartialOrd<str> for Box<Name>
impl PartialOrd<str> for Box<Name>
Source§impl PartialOrd<str> for Name
impl PartialOrd<str> for Name
Source§impl PartialOrd for Name
impl PartialOrd for Name
Source§impl ToOwned for Name
Available on crate feature alloc only.
impl ToOwned for Name
Available on crate feature
alloc only.