HasField

Trait HasField 

Source
pub trait HasField<Field, T, R>
where Field: TypedString,
{ // Required methods fn get_field<'a>(&'a self) -> &'a T where Field: 'a; fn get_field_mut<'a>(&'a mut self) -> &'a mut T where Field: 'a; fn take_field(self) -> T; }
Expand description

A trait that indicate that an anonymous struct contains a certain field.

§Generic parameters

  • Field: Typed field name, see stringz::ident!.
  • T: The type of data carried by the field.
  • R: Type used to indicate the position of the field in the struct. Usually automatically inferred by Rust.

§Example

See the section “as generic type”.

Required Methods§

Source

fn get_field<'a>(&'a self) -> &'a T
where Field: 'a,

Get the immutable reference to the data carried by the field.

Source

fn get_field_mut<'a>(&'a mut self) -> &'a mut T
where Field: 'a,

Get the mutable reference to the data carried by the field.

Source

fn take_field(self) -> T

Consume the struct and take the data carried by the field.

Implementations on Foreign Types§

Source§

impl<Field, T, R, First, Other> HasField<Field, T, R> for Tuple<First, Other>
where Field: TypedString, Self: Search<(Field, T), R>,

Source§

fn get_field<'a>(&'a self) -> &'a T
where Field: 'a,

Source§

fn get_field_mut<'a>(&'a mut self) -> &'a mut T
where Field: 'a,

Source§

fn take_field(self) -> T

Implementors§