pub struct SpannedValue<T> {
pub value: T,
pub span: Range<Span>,
}
Expand description
Helper struct to hold a value and the corresponding range.
Fields§
§value: T
The value.
span: Range<Span>
The value’s span.
Implementations§
Source§impl<T> SpannedValue<T>
impl<T> SpannedValue<T>
Sourcepub fn map_value<I>(self, map: impl FnOnce(T) -> I) -> SpannedValue<I>
pub fn map_value<I>(self, map: impl FnOnce(T) -> I) -> SpannedValue<I>
Map the value to a new type, keeping the span.
Sourcepub fn from_to_tokens(value: T) -> Selfwhere
T: ToTokens,
pub fn from_to_tokens(value: T) -> Selfwhere
T: ToTokens,
Creates a new SpannedValue
from a value
implementing ToTokens
.
Sourcepub fn new(value: T, span: impl SpanRanged) -> SpannedValue<T>
pub fn new(value: T, span: impl SpanRanged) -> SpannedValue<T>
Creates a new SpannedValue
from a value
and a span
.
Sourcepub fn call_site(value: T) -> SpannedValue<T>
pub fn call_site(value: T) -> SpannedValue<T>
Creates a new SpannedValue
with the span Span::call_site()
.
Trait Implementations§
Source§impl<T: Debug> Debug for SpannedValue<T>
impl<T: Debug> Debug for SpannedValue<T>
Source§impl<T: Default> Default for SpannedValue<T>
impl<T: Default> Default for SpannedValue<T>
Source§impl<T> SpanRanged for SpannedValue<T>
impl<T> SpanRanged for SpannedValue<T>
Source§fn span_joined(&self) -> Option<Span>
fn span_joined(&self) -> Option<Span>
Returns
Self::span_range
as a single span if possible, currently
only possible on nightly. moreAuto Trait Implementations§
impl<T> Freeze for SpannedValue<T>where
T: Freeze,
impl<T> RefUnwindSafe for SpannedValue<T>where
T: RefUnwindSafe,
impl<T> !Send for SpannedValue<T>
impl<T> !Sync for SpannedValue<T>
impl<T> Unpin for SpannedValue<T>where
T: Unpin,
impl<T> UnwindSafe for SpannedValue<T>where
T: UnwindSafe,
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
Source§impl<P, T> FromPartial<Defaulting<P>> for Twhere
T: Default + FromPartial<P>,
impl<P, T> FromPartial<Defaulting<P>> for Twhere
T: Default + FromPartial<P>,
Source§fn from_option(partial: Option<Defaulting<P>>, _error: &str) -> Result<T, Error>
fn from_option(partial: Option<Defaulting<P>>, _error: &str) -> Result<T, Error>
Source§fn join(
first: Option<SpannedValue<T>>,
second: SpannedValue<T>,
specified_twice_error: &str,
) -> Result<Option<SpannedValue<T>>>
fn join( first: Option<SpannedValue<T>>, second: SpannedValue<T>, specified_twice_error: &str, ) -> Result<Option<SpannedValue<T>>>
Defines how two arguments for the same parameter should be handled. Read more
Source§impl<T> FromPartial<T> for T
impl<T> FromPartial<T> for T
Source§fn join(
first: Option<SpannedValue<T>>,
second: SpannedValue<T>,
specified_twice_error: &str,
) -> Result<Option<SpannedValue<T>>>
fn join( first: Option<SpannedValue<T>>, second: SpannedValue<T>, specified_twice_error: &str, ) -> Result<Option<SpannedValue<T>>>
Defines how two arguments for the same parameter should be handled. Read more