Struct add_ed::Line

source ·
pub struct Line {
    pub tag: Rc<Cell<char>>,
    pub text: Rc<String>,
    /* private fields */
}
Expand description

Text data and metadata for a single line of text

Note the Rc<Cell>s placed around internal variables we wish to share between points in history while allowing modification, both in that Rc and without &mut access to the line. This is to let [History] enforce use of [History::current_mut] to edit the text, while allowing changes to other data using [History::current] (which doesn’t create undo snapshots).

Fields§

§tag: Rc<Cell<char>>

The tag set on the given line

It is stored in an Rc to have a shared overwriteable tag for all historical instances of the line.

§text: Rc<String>

The text data for a given line

It is stored in an Rc as a CoW mechanism, since it allows a shared allocation for historical states with the same text data while preventing modification of that shared state. To modify, create a new String with the data you want and put it in a new Rc in this field.

Trait Implementations§

source§

impl Debug for Line

source§

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

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

impl From<&Line> for PubLine

source§

fn from(l: &Line) -> Self

Converts to this type from the input type.
source§

impl From<&PubLine> for Line

source§

fn from(l: &PubLine) -> Self

Converts to this type from the input type.
source§

impl From<&str> for Line

source§

fn from(l: &str) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Line> for Line

source§

fn eq(&self, other: &Line) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Line

source§

impl StructuralEq for Line

source§

impl StructuralPartialEq for Line

Auto Trait Implementations§

§

impl !RefUnwindSafe for Line

§

impl !Send for Line

§

impl !Sync for Line

§

impl Unpin for Line

§

impl !UnwindSafe for Line

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for Twhere T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

source§

fn type_name(&self) -> &'static str

Gets the type name of self
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for Twhere T: AsAny + ?Sized,

source§

fn is<T>(&self) -> boolwhere T: AsAny,

Returns true if the boxed type is the same as T. Read more
source§

fn downcast_ref<T>(&self) -> Option<&T>where T: AsAny,

Forward to the method defined on the type Any.
source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>where T: AsAny,

Forward to the method defined on the type Any.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.