Skip to main content

SequenceEditor

Struct SequenceEditor 

Source
pub struct SequenceEditor<'a> { /* private fields */ }
Expand description

A transactional, source-preserving editor for one YAML sequence.

Implementations§

Source§

impl SequenceEditor<'_>

Source

pub fn sort_by( self, compare: impl FnMut(&YamlDoc, NodeId, NodeId) -> Ordering, ) -> Result<(), YamlEditError>

Stably sorts items using semantic inspection of their lossless nodes.

Source

pub fn insert( self, index: usize, value: &YamlFragment, ) -> Result<(), YamlEditError>

Inserts value before the item at index, or appends at len.

Source

pub fn move_item(self, from: usize, to: usize) -> Result<(), YamlEditError>

Moves an existing item to its index in the finished sequence.

Source

pub fn retain( self, predicate: impl FnMut(&YamlDoc, NodeId) -> bool, ) -> Result<(), YamlEditError>

Retains only items for which predicate returns true.

The predicate is called once per original item in source order. Removed items take their attached comments and other entry trivia with them.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for SequenceEditor<'a>

§

impl<'a> Freeze for SequenceEditor<'a>

§

impl<'a> RefUnwindSafe for SequenceEditor<'a>

§

impl<'a> Send for SequenceEditor<'a>

§

impl<'a> Sync for SequenceEditor<'a>

§

impl<'a> Unpin for SequenceEditor<'a>

§

impl<'a> UnsafeUnpin for SequenceEditor<'a>

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.