pub struct SubstrWrapper<const N: usize>(pub Substr<N>);
Expand description
Wrapper around Substr in order to bring extra capabilities.
use substr_iterator::SubstrWrapper;
use std::str::FromStr;
let value: [char; 3] = ['a', 'b', 'c'];
let wrapped = SubstrWrapper(value);
// implements Display
assert_eq!(wrapped.to_string(), "abc");
// parsing &str
let parsed = SubstrWrapper::from_str("abc").unwrap();
assert_eq!(wrapped, parsed);
When the serde
feature is enabled, SubstrWrapper provides a way to serde::Serialize and serde::Deserialize.
let value: [char; 3] = ['a', 'b', 'c'];
let wrapped = substr_iterator::SubstrWrapper(value);
assert_eq!(serde_json::to_string(&wrapped).unwrap(), "\"abc\"");
Tuple Fields§
§0: Substr<N>
Implementations§
Trait Implementations§
Source§impl<const N: usize> Clone for SubstrWrapper<N>
impl<const N: usize> Clone for SubstrWrapper<N>
Source§fn clone(&self) -> SubstrWrapper<N>
fn clone(&self) -> SubstrWrapper<N>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<const N: usize> Debug for SubstrWrapper<N>
impl<const N: usize> Debug for SubstrWrapper<N>
Source§impl<'de, const N: usize> Deserialize<'de> for SubstrWrapper<N>
impl<'de, const N: usize> Deserialize<'de> for SubstrWrapper<N>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<const N: usize> Display for SubstrWrapper<N>
impl<const N: usize> Display for SubstrWrapper<N>
Source§impl<const N: usize> FromStr for SubstrWrapper<N>
impl<const N: usize> FromStr for SubstrWrapper<N>
Source§impl<const N: usize> Hash for SubstrWrapper<N>
impl<const N: usize> Hash for SubstrWrapper<N>
Source§impl<const N: usize> Ord for SubstrWrapper<N>
impl<const N: usize> Ord for SubstrWrapper<N>
Source§fn cmp(&self, other: &SubstrWrapper<N>) -> Ordering
fn cmp(&self, other: &SubstrWrapper<N>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<const N: usize> PartialEq for SubstrWrapper<N>
impl<const N: usize> PartialEq for SubstrWrapper<N>
Source§impl<const N: usize> PartialOrd for SubstrWrapper<N>
impl<const N: usize> PartialOrd for SubstrWrapper<N>
Source§impl<const N: usize> Serialize for SubstrWrapper<N>
impl<const N: usize> Serialize for SubstrWrapper<N>
impl<const N: usize> Copy for SubstrWrapper<N>
impl<const N: usize> Eq for SubstrWrapper<N>
impl<const N: usize> StructuralPartialEq for SubstrWrapper<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for SubstrWrapper<N>
impl<const N: usize> RefUnwindSafe for SubstrWrapper<N>
impl<const N: usize> Send for SubstrWrapper<N>
impl<const N: usize> Sync for SubstrWrapper<N>
impl<const N: usize> Unpin for SubstrWrapper<N>
impl<const N: usize> UnwindSafe for SubstrWrapper<N>
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