devela::code::result

Struct Own

Source
pub struct Own<S, V> {
    pub s: S,
    pub v: V,
}
Expand description

A return type encapsulating an owned state S and a value V.

It is designed to be used by methods that take ownership of self, and return it alongside the operation-specific result.

By convention methods that return an Own should to be prefixed with own_, and any Result or Option should be part of the state field for the constructors, and part of the value field for most other methods, allowing self to be passed along a chain of operations.

§Methods

§General methods

Additional const methods are available when both types are Copy.

§Methods for when state is a Result

§Methods for when state is an Option

§Methods for when value is a Result

§Methods for when value is an Option

Fields§

§s: S

The state after the operation.

§v: V

The value resulting from the operation.

Implementations§

Source§

impl<S> Own<S, ()>

Source

pub const fn empty(state: S) -> Own<S, ()>

A constructor with the given state and an empty value.

Source§

impl<S, V> Own<S, V>

§General methods.

Source

pub const fn new(state: S, value: V) -> Self

A constructor with the given state and value.

Source

pub fn sv(self) -> (S, V)

Returns both state and value as a tuple.

Source

pub const fn sv_ref(&self) -> (&S, &V)

Returns shared references to both state and value.

Source

pub fn sv_mut(&mut self) -> (&mut S, &mut V)

Returns exclusive references to both state and value.

Source

pub fn s_replace(self, new_state: S) -> Self

Replaces the existing state with a new_state.

Source

pub fn v_replace(self, new_value: V) -> Self

Replaces the value with a new_value.

Source

pub fn sv_replace(self, new_state: S, new_value: V) -> Self

Replaces the existing state and value with new_state and new_value, respectively.

Source

pub fn s_wrap_ok<E>(self) -> Own<Result<S, E>, V>

Wraps the state field into Ok.

Source

pub fn s_wrap_some(self) -> Own<Option<S>, V>

Wraps the state field into Some.

Source

pub fn v_wrap_ok<E>(self) -> Own<S, Result<V, E>>

Wraps the value field into Ok.

Source

pub fn v_wrap_some(self) -> Own<S, Option<V>>

Wraps the value field into Some.

Source

pub fn s_map<T, F: FnOnce(S) -> T>(self, f: F) -> Own<T, V>

Applies a mapping function to the state.

Source

pub fn v_map<W, F: FnOnce(V) -> W>(self, f: F) -> Own<S, W>

Applies a mapping function to the value.

Source

pub fn sv_map<F, G, T, W>(self, sf: F, vf: G) -> Own<T, W>
where F: FnOnce(S) -> T, G: FnOnce(V) -> W,

Applies applies a separate mapping function to the state and value.

Source

pub fn s_eq(&self, expected: &S) -> bool
where S: PartialEq,

Returns true if the current state equals the given expected state.

Source

pub fn v_eq(&self, expected: &V) -> bool
where V: PartialEq,

Returns true if the current value equals the given expected value.

Source

pub fn sv_eq(&self, expected_state: &S, expected_value: &V) -> bool
where S: PartialEq, V: PartialEq,

Returns true if the current state and value equals the corresponding expected ones.

Source

pub fn s_assert<F: FnOnce(&S) -> bool>(self, predicate: F) -> Self

Asserts the state matches the predicate, otherwise panics.

§Panics

Panics if the predicate returns false.

Source

pub fn s_assert_or<F: FnOnce(&S) -> bool>( self, predicate: F, message: &str, ) -> Self

Asserts the state matches the predicate, otherwise panics with message.

§Panics

Panics if the predicate returns false.

Source

pub fn s_assert_eq(self, expected_state: &S) -> Self
where S: PartialEq,

Asserts the state equals expected and returns self, otherwise panics.

§Panics

Panics if the state doesn’t equal the expected state.

Source

pub fn s_assert_eq_or(self, expected_state: &S, message: &str) -> Self
where S: PartialEq,

Asserts the state equals expected and returns self, otherwise panics with message.

§Panics

Panics if the state doesn’t equal the expected state.

Source

pub fn v_assert<F: FnOnce(&V) -> bool>(self, predicate: F) -> Self

Asserts the value matches the predicate, otherwise panics.

§Panics

Panics if the predicate returns false.

Source

pub fn v_assert_or<F: FnOnce(&V) -> bool>( self, predicate: F, message: &str, ) -> Self

Asserts the value matches the predicate, otherwise panics with message.

§Panics

Panics if the predicate returns false.

Source

pub fn v_assert_eq(self, expected_value: &V) -> Self
where V: PartialEq,

Asserts the value equals expected and returns self, otherwise panics.

§Panics

Panics if the value doesn’t equal the expected value.

Source

pub fn v_assert_eq_or(self, expected_value: &V, message: &str) -> Self
where V: PartialEq,

Asserts the value equals expected and returns self, otherwise panics with message.

§Panics

Panics if the value doesn’t equal the expected value.

Source

pub fn sv_assert<F, G>(self, s_predicate: F, v_predicate: G) -> Self
where F: FnOnce(&S) -> bool, G: FnOnce(&V) -> bool,

Asserts both the state and value matches the corresponding predicates, otherwise panics.

§Panics

Panics if any predicate returns false.

Source

pub fn sv_assert_or<F, G>( self, s_predicate: F, v_predicate: G, message: &str, ) -> Self
where F: FnOnce(&S) -> bool, G: FnOnce(&V) -> bool,

Asserts both the state and value matches the corresponding predicates, otherwise panics with message.

§Panics

Panics if any predicate returns false.

Source

pub fn sv_assert_eq(self, expected_state: &S, expected_value: &V) -> Self
where S: PartialEq, V: PartialEq,

Asserts the state and value equals the corresponding expected ones, and returns self, otherwise panics.

§Panics

Panics if either the state or the value are not the expected ones.

Source

pub fn sv_assert_eq_or( self, expected_state: &S, expected_value: &V, message: &str, ) -> Self
where S: PartialEq, V: PartialEq,

Asserts the state and value equals the corresponding expected ones, and returns self, otherwise panics with message

§Panics

Panics if either the state or the value are not the expected ones.

Source§

impl<S: Copy, V: Copy> Own<S, V>

§Additional const

methods for when everything is Copy.
Source

pub const fn sv_const(self) -> (S, V)

Transforms itself into a tuple, in compile-time.

Source

pub const fn s_const_replace(self, s: S) -> Self

Replaces the state self with a new_state, in compile-time.

Source

pub const fn v_const_replace(self, v: V) -> Self

Replaces the value with a new_value, in compile-time.

Source

pub const fn sv_const_replace(self, new_state: S, new_value: V) -> Self

Replaces the state self with a new_state and the value with a new_value, in compile-time.

Source

pub const fn s_const_wrap_ok<E>(self) -> Own<Result<S, E>, V>

Wraps the state field into a Result, in compile-time.

Source

pub const fn s_const_wrap_some(self) -> Own<Option<S>, V>

Wraps the state field into an Option, in compile-time.

Source

pub const fn v_const_wrap_ok<E>(self) -> Own<S, Result<V, E>>

Wraps the value field into a Result, in compile-time.

Source

pub const fn v_const_wrap_some(self) -> Own<S, Option<V>>

Wraps the value field into an Option, in compile-time.

Source§

impl<S, E, V> Own<Result<S, E>, V>

§Additional methods for when the state is a Result.

Source

pub fn s_map_ok<T, F: FnOnce(S) -> T>(self, op: F) -> Own<Result<T, E>, V>

Maps a Result<S> to a Result<T> by applying the op function to a contained Ok value, leaving an Err value untouched.

Source

pub fn s_map_err<F, O: FnOnce(E) -> F>(self, op: O) -> Own<Result<S, F>, V>

Maps a Result<S, E> to a Result<S, F> by applying the op function to a contained Err value, leaving an Ok value untouched.

Source

pub fn s_and<T>(self, res: Result<T, E>) -> Own<Result<T, E>, V>

Returns res if the state is Ok, otherwise returns the Err value of self.

Source

pub fn s_and_then<T, F: FnOnce(S) -> Result<T, E>>( self, op: F, ) -> Own<Result<T, E>, V>

Calls op if the state is Ok, otherwise returns the Err value of self.

Source

pub const fn s_assert_ok(self) -> Self

Asserts the state is Ok and returns self, otherwise panics.

§Panics

Panics if the state is Err.

Source

pub const fn s_assert_ok_or(self, message: &'static str) -> Self

Asserts the state is Ok and returns self, otherwise panics with message.

§Panics

Panics if the state is Err.

Source

pub const fn s_assert_err(self) -> Self

Asserts the state is Err and returns self, otherwise panics.

§Panics

Panics if the state is Ok.

Source

pub const fn s_assert_err_or(self, message: &'static str) -> Self

Asserts the state is Err and returns self, otherwise panics with message.

§Panics

Panics if the state is Ok.

Source

pub fn s_unwrap(self) -> Own<S, V>

Unwraps the contained Ok(state) or panics.

§Panics

Panics if the state is Err.

Source

pub fn s_unwrap_or(self, default: S) -> Own<S, V>

Unwraps the contained Ok(state) or provides a default.

§Panics

Panics if the state is Err.

Source

pub fn s_expect(self, message: &str) -> Own<S, V>
where E: Debug,

Unwraps the contained Ok(state) or panics with a message.

§Panics

Panics if the state is Err.

Source§

impl<S: Copy, E: Copy, V: Copy> Own<Result<S, E>, V>

§const

methods for when everything is Copy and the state is a Result.
Source

pub const fn s_const_unwrap(self) -> Own<S, V>

Unwraps the contained Ok(state) or panics.

§Panics

Panics if the state is Err.

Source

pub const fn s_const_unwrap_or(self, default: S) -> Own<S, V>

Unwraps the contained Ok(state) or provides a default.

Source

pub const fn s_const_expect(self, message: &'static str) -> Own<S, V>

Unwraps the contained Ok(state) or panics with the given message.

§Panics

Panics if the state is Err.

Source§

impl<S, V> Own<Option<S>, V>

§Additional methods for when the value field is an Option.

Source

pub fn s_map_some<T, F: FnOnce(S) -> T>(self, op: F) -> Own<Option<T>, V>

Maps an Option<S> to an Option<T> by applying the op function to a contained state (if Some), or returns None (if None).

Source

pub fn s_and<T>(self, res: Option<T>) -> Own<Option<T>, V>

Returns None if the state is None, otherwise returns optb.

Source

pub fn s_and_then<T, F: FnOnce(S) -> Option<T>>( self, op: F, ) -> Own<Option<T>, V>

Returns None if the state is None, otherwise calls op with the wrapped state and returns the result.

Source

pub const fn s_assert_some(self) -> Self

Asserts the state is Some and returns self, otherwise panics.

§Panics

Panics if the state is None.

Source

pub const fn s_assert_some_or(self, message: &'static str) -> Self

Asserts the state is Some and returns self, otherwise panics with message.

§Panics

Panics if the state is None.

Source

pub const fn s_assert_none(self) -> Self

Asserts the state is None and returns self, otherwise panics.

§Panics

Panics if the state is Some.

Source

pub const fn s_assert_none_or(self, message: &'static str) -> Self

Asserts the state is None and returns self, otherwise panics with message.

§Panics

Panics if the state is Some.

Source

pub fn s_unwrap(self) -> Own<S, V>

Unwraps the contained Some(state) or panics.

§Panics

Panics if the state is None.

Source

pub fn s_unwrap_or(self, default: S) -> Own<S, V>

Unwraps the contained Some(state) or provides a default.

Source

pub fn s_expect(self, message: &str) -> Own<S, V>

Unwraps the contained Some(state) or panics with the given message.

§Panics

Panics if the state is None.

Source§

impl<S: Copy, V: Copy> Own<Option<S>, V>

§const

methods for when everything is Copy and the value is an Option.
Source

pub const fn s_const_unwrap(self) -> Own<S, V>

Unwraps the contained Some(state) or panics.

§Panics

Panics if the state is None.

Source

pub const fn s_const_unwrap_or(self, default: S) -> Own<S, V>

Unwraps the contained Some(state) or provides a default.

Source

pub const fn s_const_expect(self, message: &'static str) -> Own<S, V>

Unwraps the contained Some(state) or panics with the given message.

§Panics

Panics if the state is None.

Source§

impl<S, V, E> Own<S, Result<V, E>>

§Additional methods for when the value field is a Result.

Source

pub fn v_map_ok<W, F: FnOnce(V) -> W>(self, op: F) -> Own<S, Result<W, E>>

Maps a Result<V> to a Result<W> by applying the op function to a contained Ok value, leaving an Err value untouched.

Source

pub fn v_map_err<F, O: FnOnce(E) -> F>(self, op: O) -> Own<S, Result<V, F>>

Maps a Result<V, E> to a Result<V, F> by applying the op function to a contained Err value, leaving an Ok value untouched.

Source

pub fn v_and<W>(self, res: Result<W, E>) -> Own<S, Result<W, E>>

Returns res if the result is Ok, otherwise returns the Err value of self.

Source

pub fn v_and_then<W, F: FnOnce(V) -> Result<W, E>>( self, op: F, ) -> Own<S, Result<W, E>>

Calls op if the result is Ok, otherwise returns the Err value of self.

Source

pub const fn v_assert_ok(self) -> Self

Asserts the value is Ok and returns self, otherwise panics.

§Panics

Panics if the value is Err.

Source

pub const fn v_assert_ok_or(self, message: &'static str) -> Self

Asserts the value is Ok and returns self, otherwise panics with message.

§Panics

Panics if the value is Err.

Source

pub const fn v_assert_err(self) -> Self

Asserts the value is Err and returns self, otherwise panics.

§Panics

Panics if the value is Ok.

Source

pub const fn v_assert_err_or(self, message: &'static str) -> Self

Asserts the value is Err and returns self, otherwise panics with message.

§Panics

Panics if the value is Ok.

Source

pub fn v_unwrap(self) -> Own<S, V>

Unwraps the contained Ok(value) or panics.

§Panics

Panics if the value is Err.

Source

pub fn v_unwrap_or(self, default: V) -> Own<S, V>

Unwraps the contained Ok(value) or provides a default.

Source

pub fn v_expect(self, message: &str) -> Own<S, V>
where E: Debug,

Unwraps the contained Ok(value) or panics with a message.

§Panics

Panics if the value is Err.

Source§

impl<S: Copy, V: Copy, E: Copy> Own<S, Result<V, E>>

§const

methods for when everything is Copy and the value is a Result.
Source

pub const fn v_const_unwrap(self) -> Own<S, V>

Unwraps the contained Ok(value) or panics.

§Panics

Panics if the value is Err.

Source

pub const fn v_const_unwrap_or(self, default: V) -> Own<S, V>

Unwraps the contained Ok(value) or provides a default.

Source

pub const fn v_const_expect_const(self, message: &'static str) -> Own<S, V>

Unwraps the contained Ok(value) or panics with the given message.

§Panics

Panics if the value is Err.

Source§

impl<S, V> Own<S, Option<V>>

§Additional methods for when the value field is an Option.

Source

pub fn v_map_some<W, F: FnOnce(V) -> W>(self, op: F) -> Own<S, Option<W>>

Maps an Option<V> to an Option<W> by applying the op function to a contained value (if Some), or returns None (if None).

Source

pub fn v_and<W>(self, optb: Option<W>) -> Own<S, Option<W>>

Returns None if the value is None, otherwise returns optb.

Source

pub fn v_and_then<W, F: FnOnce(V) -> Option<W>>( self, op: F, ) -> Own<S, Option<W>>

Returns None if the value is None, otherwise calls op with the wrapped value and returns the result.

Source

pub const fn v_assert_some(self) -> Self

Asserts the value is Some and returns self, otherwise panics.

§Panics

Panics if the value is None.

Source

pub const fn v_assert_some_or(self, message: &'static str) -> Self

Asserts the value is Some and returns self, otherwise panics with message.

§Panics

Panics if the value is None.

Source

pub const fn v_assert_none(self) -> Self

Asserts the value is None and returns self, otherwise panics.

§Panics

Panics if the value is Some.

Source

pub const fn v_assert_none_or(self, message: &'static str) -> Self

Asserts the value is None and returns self, otherwise panics with message.

§Panics

Panics if the value is Some.

Source

pub fn v_unwrap(self) -> Own<S, V>

Unwraps the contained Some(value) or panics.

§Panics

Panics if the value is None.

Source

pub fn v_unwrap_or(self, default: V) -> Own<S, V>

Unwraps the contained Some(value) or provides a default.

Source

pub fn v_expect(self, message: &str) -> Own<S, V>

Unwraps the contained Some(value) or panics with the given message.

§Panics

Panics if the value is None.

Source§

impl<S: Copy, V: Copy> Own<S, Option<V>>

§const

methods for when everything is Copy and the value is an Option.
Source

pub const fn v_const_unwrap(self) -> Own<S, V>

Unwraps the contained Some(value) or panics.

§Panics

Panics if the value is None.

Source

pub const fn v_const_unwrap_or(self, default: V) -> Own<S, V>

Unwraps the contained Some(value) or provides a default.

Source

pub const fn v_const_expect(self, message: &'static str) -> Own<S, V>

Unwraps the contained Some(value) or panics with the given message.

§Panics

Panics if the value is None.

Trait Implementations§

Source§

impl<S: Clone, V: Clone> Clone for Own<S, V>

Source§

fn clone(&self) -> Self

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

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

Performs copy-assignment from source. Read more
Source§

impl<S: ConstDefault, V: ConstDefault> ConstDefault for Own<S, V>

Source§

const DEFAULT: Self

Returns the compile-time “default value” for a type.
Source§

impl<S: Debug, V: Debug> Debug for Own<S, V>

Source§

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

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

impl<S: Default, V: Default> Default for Own<S, V>

Source§

fn default() -> Self

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

impl<S: Display, V: Display> Display for Own<S, V>

Source§

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

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

impl<S: Ord, V: Ord> Ord for Own<S, V>

Source§

fn cmp(&self, other: &Self) -> Ordering

State’s ordering takes precedence over value’s ordering.

1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<S: PartialEq, V: PartialEq> PartialEq for Own<S, V>

Source§

fn eq(&self, other: &Self) -> bool

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

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<S: PartialOrd, V: PartialOrd> PartialOrd for Own<S, V>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

State’s ordering takes precedence over value’s ordering.

1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: Copy, V: Copy> Copy for Own<S, V>

Source§

impl<S: Eq, V: Eq> Eq for Own<S, V>

Auto Trait Implementations§

§

impl<S, V> Freeze for Own<S, V>
where S: Freeze, V: Freeze,

§

impl<S, V> RefUnwindSafe for Own<S, V>

§

impl<S, V> Send for Own<S, V>
where S: Send, V: Send,

§

impl<S, V> Sync for Own<S, V>
where S: Sync, V: Sync,

§

impl<S, V> Unpin for Own<S, V>
where S: Unpin, V: Unpin,

§

impl<S, V> UnwindSafe for Own<S, V>
where S: UnwindSafe, V: 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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> ByteSized for T

Source§

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
Source§

const BYTE_SIZE: usize = _

The size of this type in bytes.
Source§

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
Source§

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
Source§

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between Ptr::BYTES and BYTE_SIZE. Read more
Source§

impl<T, R> Chain<R> for T
where T: ?Sized,

Source§

fn chain<F>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Chain a function which takes the parameter by value.
Source§

fn chain_ref<F>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Chain a function which takes the parameter by shared reference.
Source§

fn chain_mut<F>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Chain a function which takes the parameter by exclusive reference.
Source§

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

Source§

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

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

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

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

Source§

fn type_id() -> TypeId

Returns the TypeId of Self. Read more
Source§

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
Source§

fn type_name(&self) -> &'static str

Returns the type name of self. Read more
Source§

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
Source§

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
Source§

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Upcasts Box<self> as Box<dyn Any>. Read more
Source§

fn downcast_ref<T: 'static>(&self) -> Option<&T>

Available on crate feature unsafe_layout only.
Returns some shared reference to the inner value if it is of type T. Read more
Source§

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>

Available on crate feature unsafe_layout only.
Returns some exclusive reference to the inner value if it is of type T. Read more
Source§

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

Source§

const NEEDS_DROP: bool = _

Know whether dropping values of this type matters, in compile-time.
Source§

fn mem_align_of<T>() -> usize

Returns the minimum alignment of the type in bytes. Read more
Source§

fn mem_align_of_val(&self) -> usize

Returns the alignment of the pointed-to value in bytes. Read more
Source§

fn mem_size_of<T>() -> usize

Returns the size of a type in bytes. Read more
Source§

fn mem_size_of_val(&self) -> usize

Returns the size of the pointed-to value in bytes. Read more
Source§

fn mem_copy(&self) -> Self
where Self: Copy,

Bitwise-copies a value. Read more
Source§

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters. Read more
Source§

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor. Read more
Source§

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor. Read more
Source§

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self. Read more
Source§

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self. Read more
Source§

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one. Read more
Source§

unsafe fn mem_zeroed<T>() -> T

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

fn mem_as_bytes(&self) -> &[u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
Source§

fn mem_as_bytes_mut(&mut self) -> &mut [u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8]. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

Source§

impl<T> Hook for T

Source§

fn hook_ref<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
Source§

fn hook_mut<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
§

impl<T> Instrument for T

§

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

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

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
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
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
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

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