Skip to main content

History

Struct History 

Source
pub struct History { /* private fields */ }
Expand description

A record of what one operation, or a chain of them, did.

Keyed by SameKey: node and placement, ignoring orientation. An edge and its reverse are the same edge, and history about one is history about both; keying on orientation would silently split every record in two.

Implementations§

Source§

impl History

Source

pub fn new() -> Self

An empty history.

Source

pub fn identity() -> Self

A history in which nothing happened to anything.

The identity for History::then: composing with it changes nothing.

Source

pub fn generate(&mut self, input: &Shape, output: Shape)

Record that input produced output as a new entity.

Source

pub fn modify(&mut self, input: &Shape, output: Shape)

Record that input became output.

Withdraws any deletion recorded for the same shape. Deletion and modification are contradictory claims, and the guard has to run both ways: clearing modifications on delete but not deletions on modify leaves a history that says both, and two callers reach opposite conclusions from it.

Source

pub fn delete(&mut self, input: &Shape)

Record that input has no image in the result.

A shape cannot be both deleted and modified: if it became something, it was not deleted. Recording a deletion drops any modification record for the same shape, so the two can never disagree.

Deletion and generation are a different matter, and coexist freely: a swept profile edge is consumed by the sweep (deleted) while generating the side face that grew from it. Anything that treats a deletion as the end of the story about a shape loses that face’s ancestry.

Source

pub fn generated(&self, input: &Shape) -> &[Shape]

New entities made from input.

Source

pub fn modified(&self, input: &Shape) -> &[Shape]

What input became.

Empty for a shape the operation left alone: “unchanged” and “modified into nothing” are different, and the second is History::is_deleted.

Source

pub fn is_deleted(&self, input: &Shape) -> bool

Whether input has no image in the result.

Source

pub fn is_affected(&self, input: &Shape) -> bool

Whether the operation touched input at all.

Source

pub fn trace<'a>(&'a self, input: &'a Shape) -> &'a [Shape]

Where input ended up: what it became, or itself if it was untouched.

The question a caller resolving a stored reference actually has. A shape an operation ignored is still there, and reporting nothing for it would make every caller special-case the common path.

Returns an empty slice only for a shape that was deleted.

Source

pub fn inputs(&self) -> Vec<Shape>

Every shape this history has something to say about.

Source

pub fn is_empty(&self) -> bool

Whether this history records nothing.

Source

pub fn then(&self, later: &Self) -> Self

This history followed by later.

Composition, and the operation everything chained depends on. For each shape either history knows about, the result answers where it ended up after both steps.

The subtlety is telling unchanged from modified into itself. A shape neither step touched must come out with no record at all, not a modification saying it became itself; otherwise composing with an empty history would invent records, and composition would not have an identity. So a modification is recorded only when one of the two steps actually reported one.

Source

pub fn chain(steps: &[Self]) -> Self

Fold a sequence of histories into one, in order.

Trait Implementations§

Source§

impl Clone for History

Source§

fn clone(&self) -> History

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for History

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for History

Source§

fn default() -> History

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.