pub struct Lexical<T> { /* private fields */ }Expand description
Value with stable lexical representation.
Some value (such as date/time) can have multiple lexical representations. When dealing with externally generated data, it is sometime preferable to preserve the lexical representation we are provided with, even if it is not in canonical form.
This type is a wrapper around a value of type T that preserves any
eventual lexical representation, found when deserializing (with
Deserialize::deserialize) or parsing (with FromStr::from_str or
str::parse).
Implementations§
Source§impl<T> Lexical<T>
impl<T> Lexical<T>
Sourcepub fn new(value: T) -> Lexical<T>
pub fn new(value: T) -> Lexical<T>
Wraps a value without any particular lexical representation.
The fmt::Display or Serialize implementation of T will be used
as lexical representation.
Sourcepub fn new_with_representation(value: T, representation: String) -> Lexical<T>
pub fn new_with_representation(value: T, representation: String) -> Lexical<T>
Wraps a value with the given lexical representation.
This representation will be used in the fmt::Display and
Serialize implementations.
It is a logical error to provide a representation that is not a valid
lexical representation of value.
Sourcepub fn from_parts(value: T, representation: Option<String>) -> Lexical<T>
pub fn from_parts(value: T, representation: Option<String>) -> Lexical<T>
Wraps a value with the given lexical optional representation.
If a representation is given, will be used in the fmt::Display and
Serialize implementations. Otherwise the T implementation of those
traits will be used.
It is a logical error to provide a representation that is not a valid
lexical representation of value.
Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Returns ownership over the inner value.
Sourcepub fn into_parts(self) -> (T, Option<String>)
pub fn into_parts(self) -> (T, Option<String>)
Breaks self into its constituting parts.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Lexical<T>
impl<'de, T> Deserialize<'de> for Lexical<T>
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Lexical<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Lexical<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<T> Ord for Lexical<T>where
T: Ord,
impl<T> Ord for Lexical<T>where
T: Ord,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T> PartialOrd<T> for Lexical<T>where
T: PartialOrd,
impl<T> PartialOrd<T> for Lexical<T>where
T: PartialOrd,
Source§impl<T> PartialOrd for Lexical<T>where
T: PartialOrd,
impl<T> PartialOrd for Lexical<T>where
T: PartialOrd,
Source§impl<T> Serialize for Lexical<T>where
T: Serialize,
impl<T> Serialize for Lexical<T>where
T: Serialize,
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl<T> Eq for Lexical<T>where
T: Eq,
Auto Trait Implementations§
impl<T> Freeze for Lexical<T>where
T: Freeze,
impl<T> RefUnwindSafe for Lexical<T>where
T: RefUnwindSafe,
impl<T> Send for Lexical<T>where
T: Send,
impl<T> Sync for Lexical<T>where
T: Sync,
impl<T> Unpin for Lexical<T>where
T: Unpin,
impl<T> UnwindSafe for Lexical<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
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
fn as_unordered(&self) -> &Unordered<T>
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> Clear for Twhere
T: InitializableFromZeroed + ?Sized,
impl<T> Clear for Twhere
T: InitializableFromZeroed + ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<'de, T, C> DeserializeTyped<'de, C> for Twhere
T: Deserialize<'de>,
impl<'de, T, C> DeserializeTyped<'de, C> for Twhere
T: Deserialize<'de>,
fn deserialize_typed<S>(
_: &C,
deserializer: S,
) -> Result<T, <S as Deserializer<'de>>::Error>where
S: Deserializer<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> InitializableFromZeroed for Twhere
T: Default,
impl<T> InitializableFromZeroed for Twhere
T: Default,
Source§unsafe fn initialize(place: *mut T)
unsafe fn initialize(place: *mut T)
Source§impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
Source§impl<T> ResourceProvider<()> for T
impl<T> ResourceProvider<()> for T
Source§fn get_resource(&self) -> &()
fn get_resource(&self) -> &()
T.