pub struct Spanned<T> { /* private fields */ }
Expand description
A spanned value, indicating the range at which it is defined in the source.
use serde_derive::Deserialize;
use toml::Spanned;
#[derive(Deserialize)]
struct Value {
s: Spanned<String>,
}
fn main() {
let t = "s = \"value\"\n";
let u: Value = toml::from_str(t).unwrap();
assert_eq!(u.s.start(), 4);
assert_eq!(u.s.end(), 11);
assert_eq!(u.s.get_ref(), "value");
assert_eq!(u.s.into_inner(), String::from("value"));
}
Implementations
sourceimpl<T> Spanned<T>
impl<T> Spanned<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the spanned value and returns the contained value.
Trait Implementations
sourceimpl<'de, T> Deserialize<'de> for Spanned<T> where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Spanned<T> where
T: Deserialize<'de>,
sourcefn deserialize<D>(deserializer: D) -> Result<Spanned<T>, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Spanned<T>, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T: Ord> Ord for Spanned<T>
impl<T: Ord> Ord for Spanned<T>
sourceimpl<T: PartialOrd> PartialOrd<Spanned<T>> for Spanned<T>
impl<T: PartialOrd> PartialOrd<Spanned<T>> for Spanned<T>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: Eq> Eq for Spanned<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Spanned<T> where
T: RefUnwindSafe,
impl<T> Send for Spanned<T> where
T: Send,
impl<T> Sync for Spanned<T> where
T: Sync,
impl<T> Unpin for Spanned<T> where
T: Unpin,
impl<T> UnwindSafe for Spanned<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more