Struct attribute_derive::parsing::SpannedValue
source · 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