Struct Optional

Source
pub struct Optional<T>(/* private fields */);
Expand description

CEL-compatible optional value type.

Optional<T> is similar to Rust’s Option<T> but designed specifically for CEL’s optional value semantics. It provides a comprehensive API for working with optional values in CEL expressions.

§Type Parameters

  • T: The type of the optional value

§Examples

use cel_cxx::{Optional, Value};

// Create optional values
let some_val = Optional::new("hello");
let none_val: Optional<String> = Optional::none();

// Convert from/to Option
let option = Some(42i64);
let optional = Optional::from_option(option);
let back_to_option = optional.into_option();

// Chain operations
let result = Optional::new(10)
    .map(|x| x * 2)
    .filter(|&x| x > 15)
    .or(Optional::new(0));

Implementations§

Source§

impl<T> Optional<T>

Source

pub fn new(value: T) -> Self

Creates a new optional value containing the given value.

§Examples
use cel_cxx::Optional;

let opt = Optional::new(42);
assert!(opt.as_option().is_some());
Source

pub fn none() -> Self

Creates an empty optional value.

§Examples
use cel_cxx::Optional;

let opt: Optional<i32> = Optional::none();
assert!(opt.as_option().is_none());
Source

pub fn into_option(self) -> Option<T>

Converts the optional into a standard Option.

§Examples
use cel_cxx::Optional;

let opt = Optional::new(42);
let option = opt.into_option();
assert_eq!(option, Some(42));
Source

pub fn from_option(opt: Option<T>) -> Self

Creates an optional from a standard Option.

§Examples
use cel_cxx::Optional;

let option = Some(42);
let opt = Optional::from_option(option);
assert_eq!(opt.into_option(), Some(42));
Source

pub fn as_option(&self) -> &Option<T>

Returns a reference to the contained Option.

§Examples
use cel_cxx::Optional;

let opt = Optional::new(42);
assert_eq!(opt.as_option(), &Some(42));
Source

pub fn as_option_mut(&mut self) -> &mut Option<T>

Returns a mutable reference to the contained Option.

§Examples
use cel_cxx::Optional;

let mut opt = Optional::new(42);
*opt.as_option_mut() = Some(100);
assert_eq!(opt.into_option(), Some(100));
Source

pub fn as_ref(&self) -> Optional<&T>

Converts from Optional<T> to Optional<&T>.

§Examples
use cel_cxx::Optional;

let opt = Optional::new("hello".to_string());
let opt_ref = opt.as_ref();
assert_eq!(opt_ref.into_option(), Some(&"hello".to_string()));
Source

pub fn as_mut(&mut self) -> Optional<&mut T>

Converts from Optional<T> to Optional<&mut T>.

§Examples
use cel_cxx::Optional;

let mut opt = Optional::new("hello".to_string());
let opt_mut = opt.as_mut();
// Can modify the contained value through opt_mut
Source

pub fn map<U, F>(self, f: F) -> Optional<U>
where F: FnOnce(T) -> U,

Maps an Optional<T> to Optional<U> by applying a function to the contained value.

§Examples
use cel_cxx::Optional;

let opt = Optional::new(5);
let doubled = opt.map(|x| x * 2);
assert_eq!(doubled.into_option(), Some(10));
Source

pub fn inspect<F>(self, f: F) -> Self
where F: FnOnce(&T),

Calls the provided closure with the contained value (if any).

§Examples
use cel_cxx::Optional;

let opt = Optional::new(42);
let result = opt.inspect(|x| println!("Value: {}", x));
assert_eq!(result.into_option(), Some(42));
Source

pub fn filter<P>(self, predicate: P) -> Self
where P: FnOnce(&T) -> bool,

Returns the optional if it contains a value, otherwise returns an empty optional.

§Examples
use cel_cxx::Optional;

let opt = Optional::new(5);
let filtered = opt.filter(|&x| x > 3);
assert_eq!(filtered.into_option(), Some(5));

let opt = Optional::new(2);
let filtered = opt.filter(|&x| x > 3);
assert_eq!(filtered.into_option(), None);
Source

pub fn or(self, other: Optional<T>) -> Optional<T>

Returns the optional if it contains a value, otherwise returns other.

§Examples
use cel_cxx::Optional;

let some = Optional::new(2);
let none: Optional<i32> = Optional::none();
let other = Optional::new(100);

assert_eq!(some.or(other.clone()).into_option(), Some(2));
assert_eq!(none.or(other).into_option(), Some(100));
Source

pub fn or_else<F>(self, f: F) -> Optional<T>
where F: FnOnce() -> Optional<T>,

Returns the optional if it contains a value, otherwise calls f and returns the result.

§Examples
use cel_cxx::Optional;

let none: Optional<i32> = Optional::none();
let result = none.or_else(|| Optional::new(42));
assert_eq!(result.into_option(), Some(42));
Source

pub fn xor(self, other: Optional<T>) -> Optional<T>

Returns Some if exactly one of self, other is Some, otherwise returns None.

§Examples
use cel_cxx::Optional;

let some = Optional::new(2);
let none: Optional<i32> = Optional::none();

assert_eq!(some.clone().xor(none.clone()).into_option(), Some(2));
assert_eq!(none.xor(some).into_option(), Some(2));
Source

pub fn and<U>(self, other: Optional<U>) -> Optional<U>

Returns the optional if it contains a value, otherwise returns an empty optional of type U.

§Examples
use cel_cxx::Optional;

let some = Optional::new(2);
let other = Optional::new("hello");
let result = some.and(other);
assert_eq!(result.into_option(), Some("hello"));
Source

pub fn and_then<U, F>(self, f: F) -> Optional<U>
where F: FnOnce(T) -> Optional<U>,

Returns an empty optional if the optional is empty, otherwise calls f with the wrapped value and returns the result.

§Examples
use cel_cxx::Optional;

let opt = Optional::new(5);
let result = opt.and_then(|x| {
    if x > 0 {
        Optional::new(x * 2)
    } else {
        Optional::none()
    }
});
assert_eq!(result.into_option(), Some(10));
Source

pub fn take(&mut self) -> Optional<T>

Takes the value out of the optional, leaving an empty optional in its place.

§Examples
use cel_cxx::Optional;

let mut opt = Optional::new(42);
let taken = opt.take();
assert_eq!(taken.into_option(), Some(42));
assert_eq!(opt.into_option(), None);
Source

pub fn take_if<P>(&mut self, predicate: P) -> Optional<T>
where P: FnOnce(&mut T) -> bool,

Takes the value out of the optional if the predicate returns true.

§Examples
use cel_cxx::Optional;

let mut opt = Optional::new(42);
let taken = opt.take_if(|x| *x > 40);
assert_eq!(taken.into_option(), Some(42));
Source

pub fn replace(&mut self, value: T) -> Optional<T>

Replaces the actual value in the optional with the value given in parameter, returning the old value if present.

§Examples
use cel_cxx::Optional;

let mut opt = Optional::new(42);
let old = opt.replace(100);
assert_eq!(old.into_option(), Some(42));
assert_eq!(opt.into_option(), Some(100));
Source

pub fn zip<U>(self, other: Optional<U>) -> Optional<(T, U)>

Zips self with another optional.

§Examples
use cel_cxx::Optional;

let opt1 = Optional::new(1);
let opt2 = Optional::new("hello");
let zipped = opt1.zip(opt2);
assert_eq!(zipped.into_option(), Some((1, "hello")));
Source

pub fn as_deref(&self) -> Optional<&<T as Deref>::Target>
where T: Deref,

Converts from Optional<T> (or &Optional<T>) to Optional<&T::Target>.

§Examples
use cel_cxx::Optional;

let opt = Optional::new("hello".to_string());
let deref_opt = opt.as_deref();
assert_eq!(deref_opt.into_option(), Some("hello"));
Source

pub fn as_deref_mut(&mut self) -> Optional<&mut <T as Deref>::Target>
where T: DerefMut,

Converts from Optional<T> (or &mut Optional<T>) to Optional<&mut T::Target>.

§Examples
use cel_cxx::Optional;

let mut opt = Optional::new("hello".to_string());
let deref_mut_opt = opt.as_deref_mut();
// Can modify the dereferenced value
Source§

impl<T, U> Optional<(T, U)>

Source

pub fn unzip(self) -> (Optional<T>, Optional<U>)

Unzips an optional containing a tuple into a tuple of optionals.

§Examples
use cel_cxx::Optional;

let opt = Optional::new((1, "hello"));
let (opt1, opt2) = opt.unzip();
assert_eq!(opt1.into_option(), Some(1));
assert_eq!(opt2.into_option(), Some("hello"));
Source§

impl<T> Optional<&T>

Source

pub fn copied(self) -> Optional<T>
where T: Copy,

Maps an Optional<&T> to an Optional<T> by copying the contents of the optional.

§Examples
use cel_cxx::Optional;

let opt_ref = Optional::new(&42);
let opt_owned = opt_ref.copied();
assert_eq!(opt_owned.into_option(), Some(42));
Source

pub fn cloned(self) -> Optional<T>
where T: Clone,

Maps an Optional<&T> to an Optional<T> by cloning the contents of the optional.

§Examples
use cel_cxx::Optional;

let hello_string = "hello".to_string();
let opt_ref = Optional::new(&hello_string);
let opt_owned = opt_ref.cloned();
assert_eq!(opt_owned.into_option(), Some("hello".to_string()));
Source§

impl<T> Optional<&mut T>

Source

pub fn copied(self) -> Optional<T>
where T: Copy,

Maps an Optional<&mut T> to an Optional<T> by copying the contents of the optional.

Source

pub fn cloned(self) -> Optional<T>
where T: Clone,

Maps an Optional<&mut T> to an Optional<T> by cloning the contents of the optional.

Source§

impl<T, E> Optional<Result<T, E>>

Source

pub fn transpose(self) -> Result<Optional<T>, E>

Transposes an Optional of a Result into a Result of an Optional.

§Examples
use cel_cxx::Optional;

let opt_result: Optional<Result<i32, &str>> = Optional::new(Ok(42));
let result_opt = opt_result.transpose();
assert_eq!(result_opt, Ok(Optional::new(42)));
Source§

impl<T> Optional<Optional<T>>

Source

pub fn flatten(self) -> Optional<T>

Flattens an Optional<Optional<T>> into an Optional<T>.

§Examples
use cel_cxx::Optional;

let nested = Optional::new(Optional::new(42));
let flattened = nested.flatten();
assert_eq!(flattened.into_option(), Some(42));

Methods from Deref<Target = Option<T>>§

1.0.0 · Source

pub fn is_some(&self) -> bool

Returns true if the option is a Some value.

§Examples
let x: Option<u32> = Some(2);
assert_eq!(x.is_some(), true);

let x: Option<u32> = None;
assert_eq!(x.is_some(), false);
1.0.0 · Source

pub fn is_none(&self) -> bool

Returns true if the option is a None value.

§Examples
let x: Option<u32> = Some(2);
assert_eq!(x.is_none(), false);

let x: Option<u32> = None;
assert_eq!(x.is_none(), true);
1.0.0 · Source

pub fn as_ref(&self) -> Option<&T>

Converts from &Option<T> to Option<&T>.

§Examples

Calculates the length of an Option<String> as an Option<usize> without moving the String. The map method takes the self argument by value, consuming the original, so this technique uses as_ref to first take an Option to a reference to the value inside the original.

let text: Option<String> = Some("Hello, world!".to_string());
// First, cast `Option<String>` to `Option<&String>` with `as_ref`,
// then consume *that* with `map`, leaving `text` on the stack.
let text_length: Option<usize> = text.as_ref().map(|s| s.len());
println!("still can print text: {text:?}");
1.0.0 · Source

pub fn as_mut(&mut self) -> Option<&mut T>

Converts from &mut Option<T> to Option<&mut T>.

§Examples
let mut x = Some(2);
match x.as_mut() {
    Some(v) => *v = 42,
    None => {},
}
assert_eq!(x, Some(42));
1.33.0 · Source

pub fn as_pin_ref(self: Pin<&Option<T>>) -> Option<Pin<&T>>

Converts from Pin<&Option<T>> to Option<Pin<&T>>.

1.33.0 · Source

pub fn as_pin_mut(self: Pin<&mut Option<T>>) -> Option<Pin<&mut T>>

Converts from Pin<&mut Option<T>> to Option<Pin<&mut T>>.

1.75.0 · Source

pub fn as_slice(&self) -> &[T]

Returns a slice of the contained value, if any. If this is None, an empty slice is returned. This can be useful to have a single type of iterator over an Option or slice.

Note: Should you have an Option<&T> and wish to get a slice of T, you can unpack it via opt.map_or(&[], std::slice::from_ref).

§Examples
assert_eq!(
    [Some(1234).as_slice(), None.as_slice()],
    [&[1234][..], &[][..]],
);

The inverse of this function is (discounting borrowing) [_]::first:

for i in [Some(1234_u16), None] {
    assert_eq!(i.as_ref(), i.as_slice().first());
}
1.75.0 · Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns a mutable slice of the contained value, if any. If this is None, an empty slice is returned. This can be useful to have a single type of iterator over an Option or slice.

Note: Should you have an Option<&mut T> instead of a &mut Option<T>, which this method takes, you can obtain a mutable slice via opt.map_or(&mut [], std::slice::from_mut).

§Examples
assert_eq!(
    [Some(1234).as_mut_slice(), None.as_mut_slice()],
    [&mut [1234][..], &mut [][..]],
);

The result is a mutable slice of zero or one items that points into our original Option:

let mut x = Some(1234);
x.as_mut_slice()[0] += 1;
assert_eq!(x, Some(1235));

The inverse of this method (discounting borrowing) is [_]::first_mut:

assert_eq!(Some(123).as_mut_slice().first_mut(), Some(&mut 123))
1.40.0 · Source

pub fn as_deref(&self) -> Option<&<T as Deref>::Target>
where T: Deref,

Converts from Option<T> (or &Option<T>) to Option<&T::Target>.

Leaves the original Option in-place, creating a new one with a reference to the original one, additionally coercing the contents via Deref.

§Examples
let x: Option<String> = Some("hey".to_owned());
assert_eq!(x.as_deref(), Some("hey"));

let x: Option<String> = None;
assert_eq!(x.as_deref(), None);
1.40.0 · Source

pub fn as_deref_mut(&mut self) -> Option<&mut <T as Deref>::Target>
where T: DerefMut,

Converts from Option<T> (or &mut Option<T>) to Option<&mut T::Target>.

Leaves the original Option in-place, creating a new one containing a mutable reference to the inner type’s Deref::Target type.

§Examples
let mut x: Option<String> = Some("hey".to_owned());
assert_eq!(x.as_deref_mut().map(|x| {
    x.make_ascii_uppercase();
    x
}), Some("HEY".to_owned().as_mut_str()));
1.0.0 · Source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the possibly contained value.

§Examples
let x = Some(4);
assert_eq!(x.iter().next(), Some(&4));

let x: Option<u32> = None;
assert_eq!(x.iter().next(), None);
1.0.0 · Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Returns a mutable iterator over the possibly contained value.

§Examples
let mut x = Some(4);
match x.iter_mut().next() {
    Some(v) => *v = 42,
    None => {},
}
assert_eq!(x, Some(42));

let mut x: Option<u32> = None;
assert_eq!(x.iter_mut().next(), None);
1.53.0 · Source

pub fn insert(&mut self, value: T) -> &mut T

Inserts value into the option, then returns a mutable reference to it.

If the option already contains a value, the old value is dropped.

See also Option::get_or_insert, which doesn’t update the value if the option already contains Some.

§Example
let mut opt = None;
let val = opt.insert(1);
assert_eq!(*val, 1);
assert_eq!(opt.unwrap(), 1);
let val = opt.insert(2);
assert_eq!(*val, 2);
*val = 3;
assert_eq!(opt.unwrap(), 3);
1.20.0 · Source

pub fn get_or_insert(&mut self, value: T) -> &mut T

Inserts value into the option if it is None, then returns a mutable reference to the contained value.

See also Option::insert, which updates the value even if the option already contains Some.

§Examples
let mut x = None;

{
    let y: &mut u32 = x.get_or_insert(5);
    assert_eq!(y, &5);

    *y = 7;
}

assert_eq!(x, Some(7));
1.83.0 · Source

pub fn get_or_insert_default(&mut self) -> &mut T
where T: Default,

Inserts the default value into the option if it is None, then returns a mutable reference to the contained value.

§Examples
let mut x = None;

{
    let y: &mut u32 = x.get_or_insert_default();
    assert_eq!(y, &0);

    *y = 7;
}

assert_eq!(x, Some(7));
1.20.0 · Source

pub fn get_or_insert_with<F>(&mut self, f: F) -> &mut T
where F: FnOnce() -> T,

Inserts a value computed from f into the option if it is None, then returns a mutable reference to the contained value.

§Examples
let mut x = None;

{
    let y: &mut u32 = x.get_or_insert_with(|| 5);
    assert_eq!(y, &5);

    *y = 7;
}

assert_eq!(x, Some(7));
1.0.0 · Source

pub fn take(&mut self) -> Option<T>

Takes the value out of the option, leaving a None in its place.

§Examples
let mut x = Some(2);
let y = x.take();
assert_eq!(x, None);
assert_eq!(y, Some(2));

let mut x: Option<u32> = None;
let y = x.take();
assert_eq!(x, None);
assert_eq!(y, None);
1.80.0 · Source

pub fn take_if<P>(&mut self, predicate: P) -> Option<T>
where P: FnOnce(&mut T) -> bool,

Takes the value out of the option, but only if the predicate evaluates to true on a mutable reference to the value.

In other words, replaces self with None if the predicate returns true. This method operates similar to Option::take but conditional.

§Examples
let mut x = Some(42);

let prev = x.take_if(|v| if *v == 42 {
    *v += 1;
    false
} else {
    false
});
assert_eq!(x, Some(43));
assert_eq!(prev, None);

let prev = x.take_if(|v| *v == 43);
assert_eq!(x, None);
assert_eq!(prev, Some(43));
1.31.0 · Source

pub fn replace(&mut self, value: T) -> Option<T>

Replaces the actual value in the option by the value given in parameter, returning the old value if present, leaving a Some in its place without deinitializing either one.

§Examples
let mut x = Some(2);
let old = x.replace(5);
assert_eq!(x, Some(5));
assert_eq!(old, Some(2));

let mut x = None;
let old = x.replace(3);
assert_eq!(x, Some(3));
assert_eq!(old, None);

Trait Implementations§

Source§

impl<T: Clone> Clone for Optional<T>

Source§

fn clone(&self) -> Optional<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Optional<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Optional<T>

Source§

fn default() -> Optional<T>

Returns the “default value” for a type. Read more
Source§

impl<T> Deref for Optional<T>

Source§

type Target = Option<T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for Optional<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: Display> Display for Optional<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> From<Option<T>> for Optional<T>

Source§

fn from(opt: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Optional<T>> for Option<T>

Source§

fn from(opt: Optional<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: IntoValue> From<Optional<T>> for Value

Source§

fn from(value: Optional<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: FromValue + TypedValue> FromValue for Optional<T>

Source§

type Output<'a> = Optional<<T as FromValue>::Output<'a>>

The output type for the from_value method. Read more
Source§

fn from_value<'a>(value: &'a Value) -> Result<Self::Output<'a>, FromValueError>

Attempts to convert a CEL Value into this type. Read more
Source§

impl<T: IntoValue> IntoValue for Optional<T>

Source§

fn into_value(self) -> Value

Converts this value into a CEL Value. Read more
Source§

impl<T: PartialEq> PartialEq for Optional<T>

Source§

fn eq(&self, other: &Optional<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for Optional<T>

Source§

type Error = FromValueError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: TryFrom<Value, Error = FromValueError> + TypedValue> TryFrom<Value> for Optional<T>

Source§

type Error = FromValueError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: TypedValue> TypedValue for Optional<T>

Source§

fn value_type() -> ValueType

Returns the CEL type for this value type. Read more
Source§

impl<T> StructuralPartialEq for Optional<T>

Auto Trait Implementations§

§

impl<T> Freeze for Optional<T>

§

impl<T> RefUnwindSafe for Optional<T>
where T: RefUnwindSafe,

§

impl<T> Send for Optional<T>
where T: Send,

§

impl<T> Sync for Optional<T>
where T: Sync,

§

impl<T> Unpin for Optional<T>

§

impl<T> UnwindSafe for Optional<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult for T
where T: IntoValue + TypedValue,

Source§

fn into_result(self) -> Result<Value, Error>

Convert the value into a CEL result.
Source§

fn value_type() -> ValueType

Get the CEL type of the resulting value.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more