pub struct NameError { /* private fields */ }
Expand description
Name error.
Implementations§
Source§impl NameError
impl NameError
Sourcepub fn valid_up_to(&self) -> usize
pub fn valid_up_to(&self) -> usize
Returns the index in the given string up to which valid name was verified.
Note that &source_str[..err.valid_up_to()]
might be invalid when valid_up_to
is zero.
In other words, it depends on target type whether the empty string is valid or not.
This error type does not assume anything about it.
§Examples
use xml_string::names::Ncname;
let err_nonempty = Ncname::from_str("foo:bar").expect_err("NCName cannot have a colon");
assert_eq!(err_nonempty.valid_up_to(), 3);
assert!(Ncname::from_str("foo").is_ok());
let err_empty = Ncname::from_str("").expect_err("NCName cannot be empty");
assert_eq!(err_empty.valid_up_to(), 0);
assert!(
Ncname::from_str("").is_err(),
"Note that `&s[..err.valid_up_to()]` is not always valid for the empty source string"
);
Trait Implementations§
Source§impl Error for NameError
impl Error for NameError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
impl Copy for NameError
impl Eq for NameError
impl StructuralPartialEq for NameError
Auto Trait Implementations§
impl Freeze for NameError
impl RefUnwindSafe for NameError
impl Send for NameError
impl Sync for NameError
impl Unpin for NameError
impl UnwindSafe for NameError
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