pdf_writer

Struct TypedDict

source
pub struct TypedDict<'a, T> { /* private fields */ }
Expand description

Writer for a dictionary mapping to a fixed type.

Implementations§

source§

impl<'a, T> TypedDict<'a, T>

source

pub fn wrap(dict: Dict<'a>) -> Self

Wrap a dictionary to make it type-safe.

source

pub fn len(&self) -> i32

The number of written pairs.

source

pub fn is_empty(&self) -> bool

Whether no pairs have been written so far.

source

pub fn pair(&mut self, key: Name<'_>, value: T) -> &mut Self
where T: Primitive,

Write a key-value pair.

source

pub fn pairs<'n>( &mut self, pairs: impl IntoIterator<Item = (Name<'n>, T)>, ) -> &mut Self
where T: Primitive,

Write a sequence of key-value pairs.

source

pub fn insert<'b>(&'b mut self, key: Name<'_>) -> <T as Rewrite<'_>>::Output
where T: Writer<'a> + Rewrite<'b>,

Start writing a pair with the typed writer.

Returns T but with its lifetime rewritten from 'a to 'b.

Trait Implementations§

source§

impl<'a, 'any, T> Rewrite<'a> for TypedDict<'any, T>

source§

type Output = TypedDict<'a, T>

The writer with the rewritten lifetime.
source§

impl<'a, T> Writer<'a> for TypedDict<'a, T>

source§

fn start(obj: Obj<'a>) -> Self

Start writing the object.

Auto Trait Implementations§

§

impl<'a, T> Freeze for TypedDict<'a, T>

§

impl<'a, T> RefUnwindSafe for TypedDict<'a, T>

§

impl<'a, T> Send for TypedDict<'a, T>

§

impl<'a, T> Sync for TypedDict<'a, T>

§

impl<'a, T> Unpin for TypedDict<'a, T>

§

impl<'a, T> !UnwindSafe for TypedDict<'a, T>

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> Finish for T

source§

fn finish(self)

Does nothing but move self, equivalent to drop.
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.