Skip to main content

LifetimesMatterLittle

Struct LifetimesMatterLittle 

Source
pub struct LifetimesMatterLittle<T>(/* private fields */);
Expand description

Marker that indicates that all lifetimes in T are just relevant for the type itself, but not for interactions. In particular, constructing it promises that:

  • The type is covariant in all lifetimes: Any InputToT<'a> could be turned into an InputToT<'b> for a shorter 'b.

    In practice, this means that no public interfaces of the type take input that needs to outlive the type (e.g. some fn set_title(self, title: &'a str) { self.title = title }).

  • It can not be observed through the type’s public interfaces how much longer its lifetime is than the reference that is passed in.

    In practice, this means that there can be a fn title(&self) -> &str, but no fn title(&self) -> &'a str.

Those properties are required to implement downcasting of generic messages into expected types, see Message::downcast_from().

In the type system, we can not convey information about incomplete types. Thus, the statement is encoded in a 'static concrete type T, but applies to the related types that vary by lifetimes.

Implementations§

Source§

impl<T> LifetimesMatterLittle<T>

Source

pub unsafe fn new() -> Self

Creates a new zero-sized marker.

§Safety

This must only be used if T has the properties required by this type.

Auto Trait Implementations§

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.