Struct kserd::ds::Kserd [−][src]
The atomic value.
Kserd
contains an optional identity (id
), and the Value
. Taken together the Kserd
object can
describe (almost) all Rust data structures. The identity can be mostly ignored for self-explanatory
data such as primitives. It can be used to name structures, and plays a special
role in unit structs and enum variants.
Kserd
dereferences mutably to Value
so all reading and mutating methods on Value
can
use directly. It is encouraged to use the methods rather than accessing the fields directly.
Kserd
implements ordering and equality, it is important to note that ordering and equality is
done only on the value, the identity is ignored.
Example
Use the methods to quickly see the data if the type is known. Mutating can be done directly.
let mut kserd = Kserd::new_str("Hi"); // access the data without needing to pattern match assert_eq!(kserd.str(), Some("Hi")); // using ctors will name your ds for you assert_eq!(kserd.id(), Some("str")); // if not of the type, nothing returned. assert_eq!(kserd.int(), None); kserd.str_mut().map(|s| { s.pop(); s.push_str("ello, world!"); }); // mutate directly. // this method has the additional effect of cloning the string. assert_eq!(kserd.str(), Some("Hello, world!"));
Fields
id: Option<Kstr<'a>>
The identity of the value.
This can be optional. Typically the identity is something like the struct or enum name.
val: Value<'a>
The Value
.
This store the actual value, which comprises of primitive types or more complex nested types such as sequences or maps.
Implementations
impl Kserd<'static>
[src]
Static lifetime constructors. These do not need a Serialize
trait.
pub const fn new_unit() -> Self
[src]
A new unit value ()
.
Example
let kserd = Kserd::new_unit(); assert_eq!(kserd.unit(), true); assert_eq!(kserd.id(), None);
pub fn new_bool(value: bool) -> Self
[src]
A new boolean value.
Example
let kserd = Kserd::new_bool(true); assert_eq!(kserd.bool(), Some(true)); assert_eq!(kserd.id(), Some("bool"));
pub fn new_num<T: NumberType>(value: T) -> Self
[src]
A new number value. The trait NumberType
is implemented on all Rust primitive
numbers so number literals can be used.
Example
let kserd = Kserd::new_num(123456); assert_eq!(kserd.uint(), Some(123456)); let kserd = Kserd::new_num(-123456); assert_eq!(kserd.int(), Some(-123456)); let kserd = Kserd::new_num(3.14); assert_eq!(kserd.float(), Some(3.14));
pub fn new_string(string: String) -> Self
[src]
A new string value. The ownership of the string is transferred and as such
the Kserd
has a static lifetime.
Example
let kserd = Kserd::new_string(String::from("Hello, world!")); assert_eq!(kserd.str(), Some("Hello, world!")); assert_eq!(kserd.id(), Some("String"));
pub fn new_barrv(byte_array: Vec<u8>) -> Self
[src]
A new byte array value. The ownership of the vector is transferred and as such the Kserd
has a static lifetime.
Example
let kserd = Kserd::new_barrv(vec![0,1,2,3]); assert_eq!(kserd.barr(), Some([0,1,2,3].as_ref())); assert_eq!(kserd.id(), Some("ByteVec"));
impl<'a> Kserd<'a>
[src]
General lifetime contructors. These do not need a Serialize
trait.
pub const fn new(value: Value<'a>) -> Self
[src]
A new Kserd
with the specified Value
.
No identity is ascribed to the Kserd
.
Example
let kserd = Kserd::new(Value::Unit); assert_eq!(kserd.val, Value::Unit); assert_eq!(kserd.id, None);
pub fn with_id<S: Into<Kstr<'a>>>(
identity: S,
value: Value<'a>
) -> Result<Self, InvalidId>
[src]
identity: S,
value: Value<'a>
) -> Result<Self, InvalidId>
A new Kserd
with a specified identity and Value
.
The identity is taken as a Kstr
, meaning it can be a reference or owned.
String
and &str
can be used as the identity. The identity must also be
valid, that is, it cannot contain certain characters or Err
will be returned.
It is recommended to construct
Kserd
in this manner rather than manually via setting theid
andval
fields as an invalid identity will not parse back from text.
Example
let kserd = Kserd::with_id("an-identity", Value::Bool(true)).unwrap(); assert_eq!(kserd.bool(), Some(true)); assert_eq!(kserd.id(), Some("an-identity")); let kserd = Kserd::with_id("<an,> in(valid.)/{identity}\\=", Value::Unit); assert_eq!(kserd.is_err(), true);
pub fn new_str(string: &'a str) -> Self
[src]
A new string value. The Kserd
borrows the string and has the same lifetime.
Example
let kserd = Kserd::new_str("Hello, world!"); assert_eq!(kserd.str(), Some("Hello, world!")); assert_eq!(kserd.id(), Some("str"));
pub fn new_barr(byte_array: &'a [u8]) -> Self
[src]
A new byte array value. The Kserd
borrows the array and has the same lifetime.
Example
let kserd = Kserd::new_barr([0,1,2,5,10].as_ref()); assert_eq!(kserd.barr(), Some([0,1,2,5,10].as_ref())); assert_eq!(kserd.id(), Some("barr"));
pub fn new_cntr<I, S>(iter: I) -> Result<Self, InvalidFieldName> where
S: Into<Kstr<'a>>,
I: IntoIterator<Item = (S, Kserd<'a>)>,
[src]
S: Into<Kstr<'a>>,
I: IntoIterator<Item = (S, Kserd<'a>)>,
Construct a new container Kserd
from a list of field-value pairs.
Example
let pass = Kserd::new_cntr(vec![ ("a", Kserd::new_num(0)) ]).unwrap(); let fail = Kserd::new_cntr(vec![ ("1 wrong/name", Kserd::new_num(0)) ]); assert_eq!(fail.is_err(), true);
pub fn new_map<I>(iter: I) -> Self where
I: IntoIterator<Item = (Kserd<'a>, Kserd<'a>)>,
[src]
I: IntoIterator<Item = (Kserd<'a>, Kserd<'a>)>,
Construct a new map value from a list of key-value pairs.
Example
let kserd = Kserd::new_map(vec![ (Kserd::new_unit(), Kserd::new_num(0)) ]);
impl<'a> Kserd<'a>
[src]
pub fn id(&self) -> Option<&str>
[src]
The identity. Same as the .id
field but mapped as a &str
.
Example
let kserd = Kserd::with_id("Hello", Value::Unit).unwrap(); assert_eq!(kserd.id(), Some("Hello"));
impl<'a> Kserd<'a>
[src]
Conversions.
pub fn into_owned(self) -> Kserd<'static>
[src]
Clones all data to make a static Kserd
.
pub fn mk_brw(&self) -> Kserd<'_>
[src]
Makes a copy of this Kserd
that references data in the this Kserd
.
This is particularly useful if you want to gaurantee that all data is of the borrowed
variety when decoding back to a data structure (see Decoder
for explanation).
There is a performance penalty as nested structures have to be rebuilt.
Example
let kserd = Kserd::new_string("Hello, world!".to_owned()); let brwed = kserd.mk_brw(); assert_eq!(kserd, brwed);
impl Kserd<'static>
[src]
pub fn enc<T: Serialize>(data: &T) -> Result<Self, Error>
[src]
Encode T
into a Kserd
.
Requires the encode feature.
Convenience function for data.serialize(Encoder)
.
See Encoder
for usage.
impl<'a> Kserd<'a>
[src]
pub fn decode<T: Deserialize<'a>>(self) -> Result<T, Error>
[src]
Attempt to decode a Kserd
into type T
.
Requires the encode feature.
Convenience function for <T as Deserialize>::deserialize(Decoder(self))
.
See Decoder
for usage.
impl<'a> Kserd<'a>
[src]
String representation.
pub fn as_str(&self) -> String
[src]
Format the Kserd
as a string using the default
FormattingConfig
.
Example
let kserd = Kserd::with_id("AStruct", Value::new_cntr(vec![ ("a", Kserd::new_num(1_010_101)), ("b", Kserd::new_num(3.14)), ("c", Kserd::new_str("Hello, world!")), ("d", Kserd::new_barrv(vec![100,150,200,225])) ]).unwrap()).unwrap(); let s = kserd.as_str(); assert_eq!( &s, r#"AStruct ( a = 1010101 b = 3.14 c = "Hello, world!" d = b91'"!Mo4' )"#);
pub fn as_str_with_config(&self, config: FormattingConfig) -> String
[src]
Format the Kserd
as a string using the specified
FormattingConfig
.
Example
use kserd::fmt::FormattingConfig; let kserd = Kserd::with_id("AStruct", Value::new_cntr(vec![ ("a", Kserd::new_num(1_010_101)), ("b", Kserd::new_num(3.14)), ("c", Kserd::new_str("Hello, world!")), ("d", Kserd::new_barrv(vec![100,150,200,225])) ]).unwrap()).unwrap(); let config = FormattingConfig { id_on_containers: false, // don't give container name width_limit: None, // all inline ..Default::default() }; let s = kserd.as_str_with_config(config); assert_eq!( &s, r#"(a = 1010101, b = 3.14, c = "Hello, world!", d = b91'"!Mo4')"# );
Methods from Deref<Target = Value<'a>>
pub fn unit(&self) -> bool
[src]
Value
is a unit value (Value::Unit
).
Example
let value = Value::Unit; assert_eq!(value.unit(), true);
pub fn bool(&self) -> Option<bool>
[src]
Value
is a boolean value.
Example
let value = Value::Bool(true); assert_eq!(value.bool(), Some(true));
pub fn bool_mut(&mut self) -> Option<&mut bool>
[src]
Value
is a boolean value. Can be altered.
Example
let mut value = Value::Bool(false); value.bool_mut().map(|x| *x = true); assert_eq!(value.bool(), Some(true));
pub fn ch(&self) -> Option<char>
[src]
Value
is a string with a single character.
Example
let value = Value::new_str("A"); assert_eq!(value.ch(), Some('A')); let value = Value::new_str("Hello, world!"); assert_eq!(value.ch(), None);
pub fn uint(&self) -> Option<u128>
[src]
Value
is an unsigned integer.
Example
let value = Value::new_num(123456); assert_eq!(value.uint(), Some(123456));
pub fn int(&self) -> Option<i128>
[src]
Value
is a signed integer. A positive integer can be both signed and unsigned
up to i128::max_value()
.
Example
let value = Value::new_num(-123456); assert_eq!(value.int(), Some(-123456));
pub fn float(&self) -> Option<f64>
[src]
Value
is a floating point number. Both signed and unsigned integers can be represented
as floats.
Example
let value = Value::new_num(-3.14); assert_eq!(value.float(), Some(-3.14));
pub fn num_mut(&mut self) -> Option<&mut Number>
[src]
Value
is a numerical value, and can be altered.
Example
let mut value = Value::new_num(123456); value.num_mut().map(|x| *x = Number::from(100)); assert_eq!(value.uint(), Some(100));
pub fn str(&self) -> Option<&str>
[src]
Value
is a string.
Example
let value = Value::new_str("Hello, world!"); assert_eq!(value.str(), Some("Hello, world!"));
pub fn str_mut(&mut self) -> Option<&mut String>
[src]
Value
is a string. Can be altered.
Clones string value if not owned.
Example
let mut value = Value::new_str("Hello"); value.str_mut().map(|x| { x.push_str(", world!"); }); assert_eq!(value.str(), Some("Hello, world!"));
pub fn barr(&self) -> Option<&[u8]>
[src]
Value
is a byte array.
Example
let value = Value::new_barr([0,1,2,5,10].as_ref()); assert_eq!(value.barr(), Some([0,1,2,5,10].as_ref()));
pub fn barr_mut(&mut self) -> Option<&mut Vec<u8>>
[src]
Value
is a byte array. Can be altered.
Clones data if not already owned.
Example
let mut value = Value::new_barr([0,1,2].as_ref()); value.barr_mut().map(|x| { x.push(3); }); assert_eq!(value.barr(), Some([0,1,2,3].as_ref()));
pub fn tuple(&self) -> Option<&Vec<Kserd<'a>>>
[src]
Value
is a tuple.
Example
let value = Value::Tuple(vec![Kserd::new_num(101)]); assert_eq!(value.tuple(), Some(&vec![Kserd::new_num(101)]));
pub fn tuple_mut(&mut self) -> Option<&mut Vec<Kserd<'a>>>
[src]
Value
is a tuple. Can be altered.
Example
let mut value = Value::Tuple(vec![Kserd::new_num(101)]); value.tuple_mut().map(|x| x.push(Kserd::new_str("Hello"))); assert_eq!( value.tuple(), Some(&vec![Kserd::new_num(101), Kserd::new_str("Hello")]) );
pub fn cntr(&self) -> Option<Accessor<&BTreeMap<Kstr<'a>, Kserd<'a>>>>
[src]
Value
is a container.
Returns an Accessor
into the fields, which has utility methods for accessing the
fields.
Example
let value = Value::new_cntr(vec![("a", Kserd::new_num(101))]).unwrap(); let accessor = value.cntr().unwrap(); assert_eq!(accessor.get_num("a"), Some(101.into()));
pub fn cntr_mut(
&mut self
) -> Option<Accessor<&mut BTreeMap<Kstr<'a>, Kserd<'a>>>>
[src]
&mut self
) -> Option<Accessor<&mut BTreeMap<Kstr<'a>, Kserd<'a>>>>
Value
is a container. Can be altered.
Returns an Accessor
into the fields, which has utility methods for accessing the
fields.
Example
let mut value = Value::new_cntr(vec![("a", Kserd::new_num(101))]).unwrap(); let mut accessor = value.cntr_mut().unwrap(); accessor.get_num_mut("a").map(|x| *x = 1.into()); assert_eq!(value, Value::new_cntr(vec![("a", Kserd::new_num(1))]).unwrap());
pub fn seq(&self) -> Option<&Vec<Kserd<'a>>>
[src]
Value
is a sequence.
Example
let value = Value::Seq(vec![Kserd::new_num(101)]); assert_eq!(value.seq(), Some(&vec![Kserd::new_num(101)]));
pub fn seq_mut(&mut self) -> Option<&mut Vec<Kserd<'a>>>
[src]
Value
is a sequence. Can be altered.
Example
let mut value = Value::Seq(vec![Kserd::new_num(101)]); value.seq_mut().map(|x| x.push(Kserd::new_str("Hello"))); assert_eq!( value.seq(), Some(&vec![Kserd::new_num(101), Kserd::new_str("Hello")]) );
pub fn tuple_or_seq(&self) -> Option<&Vec<Kserd<'a>>>
[src]
Value
is a tuple or a sequence.
As tuple and sequence share the same backing store, testing for either can be useful.
Example
let value = Value::Seq(vec![Kserd::new_num(101)]); assert_eq!(value.tuple_or_seq(), Some(&vec![Kserd::new_num(101)]));
pub fn tuple_or_seq_mut(&mut self) -> Option<&mut Vec<Kserd<'a>>>
[src]
Value
is a tuple or a sequence. Can be altered.
As tuple and sequence share the same backing store, testing for either can be useful.
Example
let mut value = Value::Tuple(vec![Kserd::new_num(101)]); value.tuple_or_seq_mut().map(|x| x.push(Kserd::new_str("Hello"))); assert_eq!( value.tuple_or_seq(), Some(&vec![Kserd::new_num(101), Kserd::new_str("Hello")]) );
pub fn map(&self) -> Option<&BTreeMap<Kserd<'a>, Kserd<'a>>>
[src]
Value
is a map.
Example
let value = Value::new_map(vec![( Kserd::new_str("a"), Kserd::new_num(3.14) )]); let num = value.map().and_then(|map| { map.get(&Kserd::new_str("a")) }); assert_eq!(num, Some(&Kserd::new_num(3.14)));
pub fn map_mut(&mut self) -> Option<&mut BTreeMap<Kserd<'a>, Kserd<'a>>>
[src]
Value
is a map. Can be altered.
Example
let mut value = Value::new_map(vec![( Kserd::new_str("a"), Kserd::new_num(3.14) )]); value.map_mut().and_then(|map| { map.get_mut(&Kserd::new_str("a")) }).map(|x| *x = Kserd::new_str("Hello")); let expect = Value::new_map(vec![( Kserd::new_str("a"), Kserd::new_str("Hello") )]); assert_eq!(value, expect);
pub fn mk_brw(&self) -> Value<'_>
[src]
Makes a copy of this Value
that references data in the this Value
.
This is particularly useful if you want to gaurantee that all data is of the borrowed
variety when decoding back to a data structure (see Decoder
for explanation).
There is a performance penalty as nested structures have to be rebuilt.
Example
let value = Value::new_string("Hello, world!".to_owned()); let brwed = value.mk_brw(); assert_eq!(value, brwed);
Trait Implementations
impl<'a> Clone for Kserd<'a>
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> Debug for Kserd<'a>
[src]
impl<'a> Deref for Kserd<'a>
[src]
impl<'a> DerefMut for Kserd<'a>
[src]
impl<'a> Display for Kserd<'a>
[src]
impl<'a> Eq for Kserd<'a>
[src]
impl<'a> Ord for Kserd<'a>
[src]
fn cmp(&self, other: &Kserd<'a>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<'a> PartialEq<Kserd<'a>> for Kserd<'a>
[src]
fn eq(&self, other: &Kserd<'_>) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialOrd<Kserd<'a>> for Kserd<'a>
[src]
fn partial_cmp(&self, other: &Kserd<'a>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> ToKserd<'a> for Kserd<'a>
[src]
fn into_kserd(self) -> Result<Kserd<'a>, ToKserdErr>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Kserd<'a>
impl<'a> Send for Kserd<'a>
impl<'a> Sync for Kserd<'a>
impl<'a> Unpin for Kserd<'a>
impl<'a> UnwindSafe for Kserd<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Conv for T
impl<T> Conv for T
impl<T> FmtForward for T
pub fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Self: Binary,
pub fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Self: Display,
pub fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Self: LowerExp,
pub fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Self: LowerHex,
pub fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Self: Octal,
pub fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Self: Pointer,
pub fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Self: UpperExp,
pub fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Self: UpperHex,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pipe for T where
T: ?Sized,
T: ?Sized,
pub fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
pub fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
R: 'a,
pub fn pipe_ref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self) -> R
) -> R where
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut Self) -> R
) -> R where
R: 'a,
pub fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
pub fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
pub fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
pub fn pipe_as_mut<'a, U, R>(
&'a mut self,
func: impl FnOnce(&'a mut U) -> R
) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut U) -> R
) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
pub fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
pub fn pipe_deref_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: DerefMut<Target = T> + Deref,
T: 'a + ?Sized,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: DerefMut<Target = T> + Deref,
T: 'a + ?Sized,
R: 'a,
impl<T> Pipe for T
impl<T> PipeAsRef for T
pub fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
Self: AsRef<T>,
T: 'a,
R: 'a,
pub fn pipe_as_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: AsMut<T>,
T: 'a,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: AsMut<T>,
T: 'a,
R: 'a,
impl<T> PipeBorrow for T
pub fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
Self: Borrow<T>,
T: 'a,
R: 'a,
pub fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
T: 'a,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
T: 'a,
R: 'a,
impl<T> PipeDeref for T
pub fn pipe_deref<'a, R>(
&'a self,
func: impl FnOnce(&'a Self::Target) -> R
) -> R where
Self: Deref,
R: 'a,
&'a self,
func: impl FnOnce(&'a Self::Target) -> R
) -> R where
Self: Deref,
R: 'a,
pub fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
impl<T> PipeRef for T
pub fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
R: 'a,
pub fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
R: 'a,
impl<T> Tap for T
pub fn tap(self, func: impl FnOnce(&Self)) -> Self
pub fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self
pub fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Self: Borrow<B>,
B: ?Sized,
pub fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Self: BorrowMut<B>,
B: ?Sized,
pub fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Self: AsRef<R>,
R: ?Sized,
pub fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Self: AsMut<R>,
R: ?Sized,
pub fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Self: Deref<Target = T>,
T: ?Sized,
pub fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
pub fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
pub fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
pub fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Self: Borrow<B>,
B: ?Sized,
pub fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Self: BorrowMut<B>,
B: ?Sized,
pub fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Self: AsRef<R>,
R: ?Sized,
pub fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Self: AsMut<R>,
R: ?Sized,
pub fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Self: Deref<Target = T>,
T: ?Sized,
pub fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
impl<T> Tap for T
pub fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
pub fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
pub fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
pub fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
U: ?Sized,
pub fn tap_ref<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
pub fn tap_ref_dbg<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
pub fn tap_ref_mut<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
pub fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
U: ?Sized,
pub fn tap_borrow<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
pub fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
pub fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
pub fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
impl<T> TapDeref for T
pub fn tap_deref<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
pub fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
pub fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
pub fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> TryConv for T
impl<T> TryConv for T
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,