Rope

Struct Rope 

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

A utf8 text rope.

The time complexity of nearly all edit and query operations on Rope are worst-case O(log N) in the length of the rope. Rope is designed to work efficiently even for huge (in the gigabytes) and pathological (all on one line) texts.

§Editing Operations

The editing operations on Rope are insertion and removal of text. For example:

let mut rope = Rope::from_str("Hello みんなさん!");
rope.remove(6..21);
rope.insert(6, "world");

assert_eq!(rope, "Hello world!");

§Query Operations

Rope provides a rich set of efficient query functions, including querying rope length in bytes/chars/lines, fetching individual chars or lines, and converting between different indexing metrics.

For example, to find the starting byte index of a given line:

use ropey::LineType::LF_CR;

let rope = Rope::from_str("Hello みんなさん!\nHow are you?\nThis text has multiple lines!");

assert_eq!(rope.line_to_byte_idx(0, LF_CR), 0);
assert_eq!(rope.line_to_byte_idx(1, LF_CR), 23);
assert_eq!(rope.line_to_byte_idx(2, LF_CR), 36);

§Slicing

You can take immutable slices of a Rope using slice():

let mut rope = Rope::from_str("Hello みんなさん!");
let middle = rope.slice(3..12);

assert_eq!(middle, "lo みん");

§Cloning

Cloning Ropes is extremely cheap, running in O(1) time and taking a small constant amount of memory for the new clone, regardless of text size. This is accomplished by data sharing between Rope clones. The memory used by clones only grows incrementally as the their contents diverge due to edits. All of this is thread safe, so clones can be sent freely between threads.

The primary intended use case for this feature is to allow asynchronous (in the general sense, not necessarily in the async sense) processing of Ropes. For example, saving a large document to disk in a separate thread while the user continues to perform edits.

Implementations§

Source§

impl Rope

Source

pub fn new() -> Rope

Creates an empty Rope.

Source

pub fn from_str(text: &str) -> Rope

Creates a Rope from a string slice.

Runs in O(N) time.

Source

pub fn from_reader<T>(reader: T) -> Result<Rope, Error>
where T: Read,

Creates a Rope from the output of a reader.

This is a convenience function, and provides no specific guarantees about performance or internal implementation aside from the runtime complexity listed below.

When more precise control over IO behavior, buffering, etc. is desired, you should handle IO yourself and use RopeBuilder to build the Rope.

Runs in O(N) time.

§Errors
  • If the reader returns an error, from_reader stops and returns that error.
  • If non-utf8 data is encountered, an IO error with kind InvalidData is returned.

Note: some data from the reader is likely consumed even if there is an error.

Source

pub fn write_to<T>(&self, writer: T) -> Result<(), Error>
where T: Write,

Writes the contents of the Rope to a writer.

This is a convenience function, and provides no specific guarantees about performance or internal implementation aside from the runtime complexity listed below.

When more precise control over IO behavior, buffering, etc. is desired, you should handle IO yourself and use the Chunks iterator to iterate through the Rope’s contents.

Runs in O(N) time.

§Errors
  • If the writer returns an error, write_to stops and returns that error.

Note: some data may have been written even if an error is returned.

Source

pub fn insert(&mut self, byte_idx: usize, text: &str)

Inserts text at byte index byte_idx.

Runs in O(M log N) time, where N is the length of the Rope and M is the length of text.

§Example
let mut rope = Rope::from_str("Hello!");
rope.insert(5, " world");

assert_eq!("Hello world!", rope);
§Panics
  • If byte_idx is out of bounds (i.e. byte_idx > len()).
  • If byte_idx is not on a char boundary.
Source

pub fn insert_char(&mut self, byte_idx: usize, ch: char)

Inserts a single char ch at byte index byte_idx.

Runs in O(log N) time.

§Example
let mut rope = Rope::from_str("Hello orld!");
rope.insert_char(6, 'w');

assert_eq!("Hello world!", rope);
§Panics
  • If byte_idx is out of bounds (i.e. byte_idx > len()).
  • If byte_idx is not on a char boundary.
Source

pub fn remove<R>(&mut self, byte_range: R)
where R: RangeBounds<usize>,

Removes the text in the given byte index range.

Uses range syntax, e.g. 2..7, 2.., etc.

Runs in O(M + log N) time, where N is the length of the Rope and M is the length of the range being removed.

§Example
let mut rope = Rope::from_str("Hello world!");
rope.remove(5..);

assert_eq!("Hello", rope);
§Panics
  • If the start of the range is greater than the end.
  • If the end of the range is out of bounds (i.e. end > len()).
  • If the range ends are not on char boundaries.
Source

pub fn slice<R>(&self, byte_range: R) -> RopeSlice<'_>
where R: RangeBounds<usize>,

Gets an immutable slice of the Rope.

Uses range syntax, e.g. 2..7, 2.., etc.

§Example
let rope = Rope::from_str("Hello world!");
let slice = rope.slice(..5);

assert_eq!("Hello", slice);

Runs in O(log N) time.

§Panics
  • If the start of the range is greater than the end.
  • If the end of the range is out of bounds (i.e. end > len()).
  • If the range ends are not on char boundaries.
Source

pub fn len(&self) -> usize

Length of the text in bytes.

Runs in O(1) time.

Source

pub fn len_utf16(&self) -> usize

Total number of utf16 code units that would be in the text if it were encoded as utf16.

Runs in best case O(1) time, worst-case O(log N).

Source

pub fn len_lines(&self, line_type: LineType) -> usize

Total number of lines in the text, according to the passed line type.

Runs in best case O(1) time, worst-case O(log N).

Source

pub fn is_char_boundary(&self, byte_idx: usize) -> bool

Returns whether byte_idx is a char boundary.

Runs in O(log N) time.

§Panics

Panics if byte_idx is out of bounds (i.e. byte_idx > len()).

Source

pub fn floor_char_boundary(&self, byte_idx: usize) -> usize

Returns the byte index of the closest char boundary less than or equal to byte_idx.

Runs in O(log N) time.

§Panics

Panics if byte_idx is out of bounds (i.e. byte_idx > len()).

Source

pub fn ceil_char_boundary(&self, byte_idx: usize) -> usize

Returns the byte index of the closest char boundary greater than or equal to byte_idx.

Runs in O(log N) time.

§Panics

Panics if byte_idx is out of bounds (i.e. byte_idx > len()).

Source

pub fn trailing_line_break_idx(&self, line_type: LineType) -> Option<usize>

If the text ends with a line break, returns its byte index. Otherwise returns None.

Note: a CRLF pair is always treated as a single unit, and thus this function will return the index of the CR in such cases, even with LineType::LF where CR is not on its own recognized as a line break.

Runs in O(log N) time.

Source

pub fn byte(&self, byte_idx: usize) -> u8

Returns the byte at byte_idx.

Runs in O(log N) time.

§Panics

Panics if byte_idx is out of bounds (i.e. byte_idx >= len()).

Source

pub fn char(&self, byte_idx: usize) -> char

Returns the char at byte_idx.

Note that this takes a byte index, not a char index.

Runs in O(log N) time.

§Panics
  • If byte_idx is out of bounds (i.e. byte_idx >= len()).
  • If byte_idx is not a char boundary.
Source

pub fn line(&self, line_idx: usize, line_type: LineType) -> RopeSlice<'_>

Returns the line at line_idx, according to the given line type.

Note: lines are zero-indexed.

Runs in O(log N) time.

§Panics

Panics if line_idx is out of bounds (i.e. line_idx >= len_lines()).

Source

pub fn chunk(&self, byte_idx: usize) -> (&str, usize)

Returns the chunk containing the byte at byte_idx.

Also returns the byte index of the beginning of the chunk.

Note: for convenience, a one-past-the-end byte_idx returns the last chunk of the RopeSlice.

Runs in O(log N) time.

§Panics

Panics if byte_idx is out of bounds (i.e. byte_idx > len()).

Source

pub fn byte_to_utf16_idx(&self, byte_idx: usize) -> usize

Returns the utf16 code unit index of the given byte.

Ropey stores text internally as utf8, but sometimes it is necessary to interact with external APIs that still use utf16. This function is primarily intended for such situations, and is otherwise not very useful.

Note: if the byte is not on a char boundary, this returns the utf16 code unit index corresponding to the char that the byte belongs to.

Runs in O(log N) time.

§Panics

Panics if byte_idx is out of bounds (i.e. byte_idx > len()).

Source

pub fn utf16_to_byte_idx(&self, utf16_idx: usize) -> usize

Returns the byte index of the given utf16 code unit.

Ropey stores text internally as utf8, but sometimes it is necessary to interact with external APIs that still use utf16. This function is primarily intended for such situations, and is otherwise not very useful.

Note: if the utf16 code unit is in the middle of a char, returns the byte index of the char that it belongs to.

Runs in O(log N) time.

§Panics

Panics if utf16_cu_idx is out of bounds (i.e. utf16_idx > len_utf16()).

Source

pub fn byte_to_line_idx(&self, byte_idx: usize, line_type: LineType) -> usize

Returns the line index of the line that the given byte belongs to.

Notes:

  • Counts lines according to the passed line type.
  • Lines are zero-indexed. Therefore this is functionally equivalent to counting the line breaks before the specified byte.
  • byte_idx can be one-past-the-end, which will return the last line index.

Runs in O(log N) time.

§Panics

Panics if byte_idx is out of bounds (i.e. byte_idx > len()).

Source

pub fn line_to_byte_idx(&self, line_idx: usize, line_type: LineType) -> usize

Returns the byte index of the start of the given line.

Notes:

  • Counts lines according to the passed line type.
  • Lines are zero-indexed.
  • line_idx can be one-past-the-end, which will return one-past-the-end byte index.

Runs in O(log N) time.

§Panics

Panics if line_idx is out of bounds (i.e. line_idx > len_lines()).

Source

pub fn bytes(&self) -> Bytes<'_>

Creates an iterator over the bytes of the Rope.

Runs in O(log N) time.

Source

pub fn bytes_at(&self, byte_idx: usize) -> Bytes<'_>

Creates an iterator over the bytes of the Rope, starting at byte byte_idx.

If byte_idx == len() then an iterator at the end of the Rope is created (i.e. next() will return None).

Runs in O(log N) time.

§Panics

Panics if byte_idx is out of bounds (i.e. byte_idx > len()).

Source

pub fn chars(&self) -> Chars<'_>

Creates an iterator over the chars of the Rope.

Runs in O(log N) time.

Source

pub fn chars_at(&self, byte_idx: usize) -> Chars<'_>

Creates an iterator over the chars of the Rope, starting at byte_idx.

Note that this takes a byte index, not a char index.

If byte_idx == len() then an iterator at the end of the Rope is created (i.e. next() will return None).

Runs in O(log N) time.

§Panics
  • If byte_idx is out of bounds (i.e. byte_idx > len()).
  • If byte_idx is not a char boundary.
Source

pub fn char_indices(&self) -> CharIndices<'_>

Creates an iterator over the chars of the Rope and their byte positions.

On each call to next or prev this iterator returns the byte index where the returned character starts.

Runs in O(log N) time.

Source

pub fn char_indices_at(&self, byte_idx: usize) -> CharIndices<'_>

Creates an iterator over the chars of the Rope and their byte positions, starting at byte_idx.

Note that this takes a byte index, not a char index.

If byte_idx == len() then an iterator at the end of the Rope is created (i.e. next() will return None).

On each call to next or prev this iterator returns the byte index where the returned character starts.

Runs in O(log N) time.

§Panics
  • If byte_idx is out of bounds (i.e. byte_idx > len()).
  • If byte_idx is not a char boundary.
Source

pub fn lines(&self, line_type: LineType) -> Lines<'_>

Creates an iterator over the lines of the Rope.

Note: the iterator will iterate over lines according to the passed line type.

Runs in O(log N) time.

Source

pub fn lines_at(&self, line_idx: usize, line_type: LineType) -> Lines<'_>

Creates an iterator over the lines of the Rope, starting at line line_idx.

Notes:

  • The iterator will iterate over lines according to the passed line type.
  • If line_idx == len_lines() then an iterator at the end of the Rope is created (i.e. next() will return None).

Runs in O(log N) time.

§Panics

Panics if line_idx is out of bounds (i.e. line_idx > len_lines()).

Source

pub fn chunks(&self) -> Chunks<'_>

Creates an iterator over the chunks of the Rope.

Runs in O(log N) time.

Source

pub fn chunks_at(&self, byte_idx: usize) -> (Chunks<'_>, usize)

Creates an iterator over the chunks of the Rope, with the iterator starting at the chunk containing byte_idx.

Also returns the byte index of the beginning of the chunk to be yielded by next().

If byte_idx == len() an iterator at the end of the Rope (yielding None on a call to next()) is created, and the returned byte index is the end of the text.

Runs in O(log N) time.

§Panics

Panics if byte_idx is out of bounds (i.e. byte_idx > len()).

Source

pub fn chunk_cursor(&self) -> ChunkCursor<'_>

Creates a cursor for navigating the chunks of the text, starting on the first chunk.

Runs in O(log N) time.

Source

pub fn chunk_cursor_at(&self, byte_idx: usize) -> ChunkCursor<'_>

Creates a cursor for navigating the chunks of the text, with the cursor starting at the chunk containing byte_idx.

For convenience, byte_idx == len() is accepted, and puts the cursor on the last chunk. Note that for non-zero-length texts this is redundant with byte_idx == len() - 1.

Runs in O(log N) time.

§Panics

Panics if byte_idx is out of bounds (i.e. byte_idx > len()).

Source

pub fn as_str(&self) -> Option<&str>

Returns the text as a string slice if it’s contiguous in memory.

Source§

impl Rope

Non-panicking versions of some of Rope’s methods.

Source

pub fn try_insert(&mut self, byte_idx: usize, text: &str) -> Result<(), Error>

Non-panicking version of insert().

On failure this leaves the rope untouched and returns the cause of the failure.

Source

pub fn try_insert_char( &mut self, byte_idx: usize, ch: char, ) -> Result<(), Error>

Non-panicking version of insert_char().

On failure this leaves the rope untouched and returns the cause of the failure.

Source

pub fn try_remove<R>(&mut self, byte_range: R) -> Result<(), Error>
where R: RangeBounds<usize>,

Non-panicking version of remove().

On failure this leaves the rope untouched and returns the cause of the failure.

Source

pub fn try_slice<R>(&self, byte_range: R) -> Result<RopeSlice<'_>, Error>
where R: RangeBounds<usize>,

Non-panicking version of slice().

On failure this returns the cause of the failure.

Source

pub fn get_byte(&self, byte_idx: usize) -> Option<u8>

Non-panicking version of byte().

If byte_idx is out of bounds, returns None.

Source

pub fn get_char(&self, byte_idx: usize) -> Result<char, Error>

Non-panicking version of char().

Will fail if byte_idx is either:

  • Not a char boundary.
  • Out of bounds.

On failure returns the cause of failure.

Source

pub fn get_line( &self, line_idx: usize, line_type: LineType, ) -> Option<RopeSlice<'_>>

Non-panicking version of line().

If line_idx is out of bounds, returns None.

Source

pub fn get_chunk(&self, byte_idx: usize) -> Option<(&str, usize)>

Non-panicking version of chunk().

If byte_idx is out of bounds, returns None.

Trait Implementations§

Source§

impl Clone for Rope

Source§

fn clone(&self) -> Rope

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Rope

Source§

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

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

impl Default for Rope

Source§

fn default() -> Rope

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

impl Display for Rope

Source§

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

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

impl<'a> From<&'a Rope> for Option<&'a str>

Attempts to borrow the text contents, but will return None if the contents is not contiguous in memory.

Runs in O(1) time.

Source§

fn from(r: &'a Rope) -> Option<&'a str>

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for Rope

Source§

fn from(s: &'a str) -> Rope

Converts to this type from the input type.
Source§

impl<'a> From<Cow<'a, str>> for Rope

Source§

fn from(s: Cow<'a, str>) -> Rope

Converts to this type from the input type.
Source§

impl From<RopeSlice<'_>> for Rope

Source§

fn from(rs: RopeSlice<'_>) -> Rope

Converts to this type from the input type.
Source§

impl From<String> for Rope

Source§

fn from(s: String) -> Rope

Converts to this type from the input type.
Source§

impl<'a> FromIterator<&'a str> for Rope

Source§

fn from_iter<T>(iter: T) -> Rope
where T: IntoIterator<Item = &'a str>,

Creates a value from an iterator. Read more
Source§

impl<'a> FromIterator<Cow<'a, str>> for Rope

Source§

fn from_iter<T>(iter: T) -> Rope
where T: IntoIterator<Item = Cow<'a, str>>,

Creates a value from an iterator. Read more
Source§

impl FromIterator<String> for Rope

Source§

fn from_iter<T>(iter: T) -> Rope
where T: IntoIterator<Item = String>,

Creates a value from an iterator. Read more
Source§

impl Hash for Rope

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Rope

Source§

fn cmp(&self, other: &Rope) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<&str> for Rope

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Cow<'_, str>> for Rope

Source§

fn eq(&self, other: &Cow<'_, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Rope> for &str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Rope> for str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<RopeSlice<'_>> for Rope

Source§

fn eq(&self, other: &RopeSlice<'_>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<String> for Rope

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for Rope

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Rope

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Rope

Source§

fn partial_cmp(&self, other: &Rope) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl RopeExt for Rope

Source§

fn slice_line(&self, row: usize) -> RopeSlice<'_>

Return a line slice at the given row (0-based) index. including \r if present, but not \n. Read more
Source§

fn slice_lines(&self, rows_range: Range<usize>) -> RopeSlice<'_>

Return a slice of rows in the given range (0-based, end exclusive). Read more
Source§

fn iter_lines(&self) -> RopeLines<'_>

Return an iterator over all lines in the rope. Read more
Source§

fn line_len(&self, row: usize) -> usize

Return the length of the row (0-based) in characters, including \r if present, but not \n. Read more
Source§

fn line_start_offset(&self, row: usize) -> usize

Start offset of the line at the given row (0-based) index. Read more
Source§

fn offset_to_point(&self, offset: usize) -> Point

Get point (row, column) from the given byte offset. Read more
Source§

fn point_to_offset(&self, point: Point) -> usize

Get byte offset from the given point (row, column). Read more
Source§

fn position_to_offset(&self, pos: &Position) -> usize

Get the byte offset from the given line, column Position (0-based). Read more
Source§

fn offset_to_position(&self, offset: usize) -> Position

Get the line, column Position (0-based) from the given byte offset. Read more
Source§

fn line_end_offset(&self, row: usize) -> usize

Line the end offset (including \n) of the line at the given row (0-based) index. Read more
Source§

fn lines_len(&self) -> usize

Return the number of lines in the rope. Read more
Source§

fn char_at(&self, offset: usize) -> Option<char>

Get char at the given offset (byte). Read more
Source§

fn word_range(&self, offset: usize) -> Option<Range<usize>>

Get the word byte range at the given byte offset (0-based).
Source§

fn word_at(&self, offset: usize) -> String

Get word at the given byte offset (0-based).
Source§

fn offset_utf16_to_offset(&self, offset_utf16: usize) -> usize

Convert offset in UTF-16 to byte offset (0-based). Read more
Source§

fn offset_to_offset_utf16(&self, offset: usize) -> usize

Convert byte offset (0-based) to offset in UTF-16. Read more
Source§

fn replace(&mut self, range: Range<usize>, new_text: &str)

Replace the text in the given byte range with new text. Read more
Source§

fn clip_offset(&self, offset: usize, bias: Bias) -> usize

Get a clipped offset (avoid in a char boundary). Read more
Source§

impl Eq for Rope

Auto Trait Implementations§

§

impl Freeze for Rope

§

impl RefUnwindSafe for Rope

§

impl Send for Rope

§

impl Sync for Rope

§

impl Unpin for Rope

§

impl UnwindSafe for Rope

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

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

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<K> MapSeekTarget<K> for K
where K: Ord,

Source§

fn cmp_cursor(&self, cursor_location: &K) -> Ordering

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,