Property

Struct Property 

Source
pub struct Property<'a, T, P, I: 'a + Init<T, P>> { /* private fields */ }
Expand description

Identifies a property that is present on objects of the appropriate Subject.

§Property Lifetime

The lifetime of a reference to a property on an object is limited by both the object and the property itself. This allows memory to be reclaimed/reused for properties that have been dropped.

use dynprops::{Subject, Dynamic};

let subject = Subject::new();
let prop = subject.new_prop_const_init(5);
let mut obj = Dynamic::new(&subject);
let x = &mut obj[&prop];
drop(prop);
*x = 10; // ERROR: This reference requires prop to be alive

Implementations§

Source§

impl<'a, T, P, I: Init<T, P>> Property<'a, T, P, I>

Source

pub fn subject(&self) -> &Subject<T>

Gets the Subject this property is associated with. This defines which Dynamics and Extendeds contain this property.

Source§

impl<'a, T, P, I: Init<T, P> + Sync> Property<'a, T, P, I>

Source

pub fn into_dyn_init(self) -> DynInitProperty<'a, T, P>

Converts this property into a DynInitProperty by wrapping its initializer in a DynInit. Note that this will add overhead if it is already a DynInitProperty.

Trait Implementations§

Source§

impl<'a, T, P, I: Init<T, P>> Drop for Property<'a, T, P, I>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, 'b, T, P, I: Init<T, P>> Index<&'b Property<'a, T, P, I>> for Extended<'b, T>

Source§

type Output = P

The returned type after indexing.
Source§

fn index(&self, index: &Property<'a, T, P, I>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, 'b, T, P, I: Init<T, P>> IndexMut<&'b Property<'a, T, P, I>> for Extended<'b, T>

Source§

fn index_mut(&mut self, index: &Property<'a, T, P, I>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'a, T, P, I> Freeze for Property<'a, T, P, I>
where I: Freeze,

§

impl<'a, T, P, I> RefUnwindSafe for Property<'a, T, P, I>
where I: RefUnwindSafe,

§

impl<'a, T, P, I> Send for Property<'a, T, P, I>
where I: Send,

§

impl<'a, T, P, I> Sync for Property<'a, T, P, I>
where I: Sync,

§

impl<'a, T, P, I> Unpin for Property<'a, T, P, I>
where I: Unpin,

§

impl<'a, T, P, I> UnwindSafe for Property<'a, T, P, I>
where I: 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.