Skip to main content

DocumentState

Struct DocumentState 

Source
pub struct DocumentState<T> { /* private fields */ }
Expand description

A binding’s document-wide state, one value of the Value table: bound globally, as the \global macros and registers of the package it stands for are, so a rollback (begin_assignment_journal: a rehearsal, a title-page check) puts it back, where a thread-local would keep what the discarded run did (FRONTMATTER_SINGLE_ENGINE_PLAN.md “What a rollback leaves”). It changes in place, unless an open journal holds it: the first change under a journal works on a copy, so a list a binding grows costs no more than a thread-local’s outside one.

Implementations§

Source§

impl<T: Clone + Default + 'static> DocumentState<T>

Source

pub const fn new(key: &'static str) -> Self

Source

pub fn read<R>(&self, read: impl FnOnce(&T) -> R) -> R

Read the state; the default where nothing was changed yet.

Source

pub fn update<R>(&self, change: impl FnOnce(&mut T) -> R) -> R

Change the state; change must not reach this same state again.

Auto Trait Implementations§

§

impl<T> Freeze for DocumentState<T>

§

impl<T> RefUnwindSafe for DocumentState<T>

§

impl<T> Send for DocumentState<T>

§

impl<T> Sync for DocumentState<T>

§

impl<T> Unpin for DocumentState<T>

§

impl<T> UnsafeUnpin for DocumentState<T>

§

impl<T> UnwindSafe for DocumentState<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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.