[][src]Struct xml_string::names::Name

#[repr(transparent)]pub struct Name(_);

String slice for Name.

Implementations

impl Name[src]

pub fn from_str(s: &str) -> Result<&Self, NameError>[src]

Creates a new &Name.

Failures

Fails if the given string is not a valid Name.

Examples

let name = Name::from_str("hello")?;
assert_eq!(name, "hello");

assert!(Name::from_str("").is_err(), "Empty string is not a Name");
assert!(Name::from_str("foo bar").is_err(), "Whitespace is not allowed");

#[must_use]pub unsafe fn new_unchecked(s: &str) -> &Self[src]

Creates a new &Name without validation.

Safety

The given string should be a valid Name.

Examples

let name = unsafe {
    Name::new_unchecked("hello")
};
assert_eq!(name, "hello");

#[must_use]pub fn as_str(&self) -> &str[src]

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");

pub fn parse_next(s: &str) -> Result<(&Self, &str), NameError>[src]

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());

pub fn into_boxed_str(self: Box<Self>) -> Box<str>[src]

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

impl AsRef<Name> for Name[src]

impl AsRef<Name> for Ncname[src]

impl AsRef<Name> for Qname[src]

impl AsRef<Nmtoken> for Name[src]

impl AsRef<str> for Name[src]

impl<'_> Debug for &'_ Name[src]

impl<'_> Display for &'_ Name[src]

impl Eq for Name[src]

impl<'_> From<&'_ Name> for Box<Name>[src]

impl<'_> From<&'_ Name> for Rc<Name>[src]

impl<'_> From<&'_ Name> for Arc<Name>[src]

impl<'a> From<&'a Name> for &'a Nmtoken[src]

impl<'a> From<&'a Ncname> for &'a Name[src]

impl<'a> From<&'a Qname> for &'a Name[src]

impl Hash for Name[src]

impl Ord for Name[src]

impl<'_> PartialEq<&'_ Name> for str[src]

impl<'_> PartialEq<&'_ String> for Name[src]

impl<'_> PartialEq<&'_ str> for Name[src]

impl PartialEq<Box<str, Global>> for Name[src]

impl<'_> PartialEq<Cow<'_, str>> for Name[src]

impl PartialEq<Name> for Name[src]

impl PartialEq<Name> for str[src]

impl<'_> PartialEq<Name> for &'_ str[src]

impl PartialEq<Name> for String[src]

impl<'_> PartialEq<Name> for &'_ String[src]

impl PartialEq<Name> for Box<str>[src]

impl<'_> PartialEq<Name> for Cow<'_, str>[src]

impl PartialEq<String> for Name[src]

impl PartialEq<str> for Name[src]

impl<'_> PartialEq<str> for &'_ Name[src]

impl<'_> PartialOrd<&'_ Name> for str[src]

impl<'_> PartialOrd<&'_ String> for Name[src]

impl<'_> PartialOrd<&'_ str> for Name[src]

impl PartialOrd<Box<str, Global>> for Name[src]

impl<'_> PartialOrd<Cow<'_, str>> for Name[src]

impl PartialOrd<Name> for Name[src]

impl PartialOrd<Name> for str[src]

impl<'_> PartialOrd<Name> for &'_ str[src]

impl PartialOrd<Name> for String[src]

impl<'_> PartialOrd<Name> for &'_ String[src]

impl PartialOrd<Name> for Box<str>[src]

impl<'_> PartialOrd<Name> for Cow<'_, str>[src]

impl PartialOrd<String> for Name[src]

impl PartialOrd<str> for Name[src]

impl<'_> PartialOrd<str> for &'_ Name[src]

impl StructuralEq for Name[src]

impl StructuralPartialEq for Name[src]

impl ToOwned for Name[src]

type Owned = Box<Name>

The resulting type after obtaining ownership.

impl<'a> TryFrom<&'a Name> for &'a Ncname[src]

type Error = NameError

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a Nmtoken> for &'a Name[src]

type Error = NameError

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a str> for &'a Name[src]

type Error = NameError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for Name

impl Send for Name

impl Sync for Name

impl Unpin for Name

impl UnwindSafe for Name

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]