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