Struct ChildInfoMeta

Source
pub struct ChildInfoMeta<M>(/* private fields */);
Expand description

Having a struct with (one) named field (for example, its), instead of a (one field) tuple struct, could make some code “nicer”.

#[repr(transparent)]
pub struct ChildInfoMeta<M> {
    /* Not called `it`, so as not to confuse it with iterators.*/
    pub its: (M, /*...*/),
}

However, that would be useful mostly for either

  • accessing the (only) field, but that we can also dereference with asterisk (through Deref and DerefMut). Or
  • accessing the anonymous/positional field(s) of the underlying tuple. But for that we have our named accessor methods, so we don’t need to access it through/by specifying the wrapped tuple itself. So we don’t need any of that much.

Instead, the consumers benefit more from easily destructuring our wrappers struct into its (only) positional/anonymous field, especially so they destructure the underlying tuple into its fields (and give them names as local variables).

Why anonymous tuples (with nameless fields)? Brevity of positional constructor. And pattern matching.

Implementations§

Source§

impl<M> ChildInfoMeta<M>

Source

pub fn child(&self) -> &ChildProcess

Useful if we don’t want to publish the wrapped field.

Source

pub fn info(&self) -> &ChildInfo

Source

pub fn meta(&self) -> &M

Only for non-Copy, or if Copy but deemed large.

If Copy and primitive, then this function doesn’t return a reference, but the field value.

Source

pub fn meta_mut(&mut self) -> &mut M

Source§

impl<M> ChildInfoMeta<M>
where M: Copy,

Only for Copy, and only if NOT primitive.

Rename to meta_copy() for non-primitive types, so that its cost would be evident everywhere it’s used.

Source

pub fn meta_copy(&self) -> M

Auto Trait Implementations§

§

impl<M> Freeze for ChildInfoMeta<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for ChildInfoMeta<M>
where M: RefUnwindSafe,

§

impl<M> Send for ChildInfoMeta<M>
where M: Send,

§

impl<M> Sync for ChildInfoMeta<M>
where M: Sync,

§

impl<M> Unpin for ChildInfoMeta<M>
where M: Unpin,

§

impl<M> UnwindSafe for ChildInfoMeta<M>
where M: 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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