Struct biblatex::Spanned

source ·
pub struct Spanned<T> {
    pub v: T,
    pub span: Range<usize>,
}
Expand description

A value with the span it corresponds to in the source code.

Spans can be detached, this means that they deliberately do not point into the source code. Such spans are created when manually setting fields with an empty bibliography or after parsing a file. Detached spans do not indicate valid index ranges in the source files and must not be used as such. A spanned item can be checked for detachment by calling Self::is_detached.

Fields§

§v: T

The spanned value.

§span: Range<usize>

The location in source code of the value.

Implementations§

source§

impl<T> Spanned<T>

source

pub fn new(v: T, span: Range<usize>) -> Self

Create a new instance from a value and its span.

source

pub fn zero(v: T) -> Self

Create a new instance with a value and a zero-length span.

source

pub fn detached(v: T) -> Self

Create a new instance with a detached span.

source

pub fn is_detached(&self) -> bool

Whether the span is detached.

source

pub fn as_ref(&self) -> Spanned<&T>

Convert from &Spanned<T> to Spanned<&T>

source

pub fn map<F, U>(self, f: F) -> Spanned<U>where F: FnOnce(T) -> U,

Map the value using a function keeping the span.

Trait Implementations§

source§

impl<T: Clone> Clone for Spanned<T>

source§

fn clone(&self) -> Spanned<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Spanned<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: PartialEq> PartialEq for Spanned<T>

source§

fn eq(&self, other: &Spanned<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq> Eq for Spanned<T>

source§

impl<T> StructuralEq for Spanned<T>

source§

impl<T> StructuralPartialEq 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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.