Skip to main content

ElementSort

Struct ElementSort 

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

A sort of an array’s elements, waiting to be told how to order them.

Built by CstArray::sort_elements.

Implementations§

Source§

impl<'a> ElementSort<'a>

Source

pub fn pin_comment_headers(self) -> Self

Leaves a comment that heads a group of elements where it was written.

Behaves like PropertySort::pin_comment_headers.

Source

pub fn pin_comment_headers_with( self, rule: impl FnMut(&CstNode, &[CstComment]) -> usize + 'a, ) -> Self

Decides for each element how much of what was written above it is a heading for what follows rather than part of the element.

Behaves like PropertySort::pin_comment_headers_with.

Source

pub fn within_groups(self) -> Self

Sorts each run of elements between blank lines on its own, so that no element crosses one.

Behaves like PropertySort::within_groups.

Source

pub fn by(self, compare: impl FnMut(&CstNode, &CstNode) -> Ordering)

Sorts the elements with the given comparator.

Behaves like PropertySort::by.

Source

pub fn by_key<K: Ord>(self, key: impl FnMut(&CstNode) -> K)

Sorts the elements by a key, which is worked out once per element.

Behaves like PropertySort::by_key.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ElementSort<'a>

§

impl<'a> !Send for ElementSort<'a>

§

impl<'a> !Sync for ElementSort<'a>

§

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

§

impl<'a> Freeze for ElementSort<'a>

§

impl<'a> Unpin for ElementSort<'a>

§

impl<'a> UnsafeUnpin for ElementSort<'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.