text_buffer

Struct Buffer

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

A Gap buffer. This represents the text of a buffer, and allows for efficient insertion and deletion of text.

Implementations§

Source§

impl Buffer

Source

pub fn new() -> Self

Source

pub fn with_gap(gap: usize) -> Self

Source

pub fn insert_char(&mut self, chr: char)

Source

pub fn insert(&mut self, slice: &str)

Source

pub fn delete_backwards(&mut self, size: usize)

Source

pub fn delete_forwards(&mut self, size: usize)

Source

pub fn delete_range(&mut self, beg: usize, end: usize)

Source

pub fn cursor(&self) -> Position

Source

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

Source

pub fn move_gap_out_of(&mut self, range: impl RangeBounds<usize>)

Source

pub fn set_cursor(&mut self, pos: usize)

Source

pub fn len_bytes(&self) -> usize

Source

pub const fn len_chars(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

pub fn char_to_byte(&self, pos: usize) -> usize

Source

pub fn byte_to_char(&self, pos: usize) -> usize

Source

pub fn as_str(&mut self) -> &str

Source

pub fn slice(&self, bounds: impl RangeBounds<usize>) -> (&str, &str)

Trait Implementations§

Source§

impl Debug for Buffer

Source§

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

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

impl Default for Buffer

Source§

fn default() -> Buffer

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

impl Display for Buffer

Source§

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

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

impl From<&str> for Buffer

Source§

fn from(data: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Buffer

Source§

fn from(data: String) -> Self

Converts to this type from the input type.
Source§

impl GetSize for Buffer

Source§

fn get_heap_size(&self) -> usize

Determines how many bytes this object occupies inside the heap. Read more
Source§

fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>( &self, tracker: TRACKER, ) -> (usize, TRACKER)

Determines how many bytes this object occupies inside the heap while using a tracker. Read more
§

fn get_stack_size() -> usize

Determines how may bytes this object occupies inside the stack. Read more
§

fn get_size(&self) -> usize

Determines the total size of the object. Read more
§

fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)
where T: GetSizeTracker,

Determines the total size of the object while using a tracker. Read more
Source§

impl<T> PartialEq<T> for Buffer
where T: Deref<Target = str>,

Source§

fn eq(&self, other: &T) -> 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 Buffer

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.

Auto Trait Implementations§

§

impl Freeze for Buffer

§

impl RefUnwindSafe for Buffer

§

impl Send for Buffer

§

impl Sync for Buffer

§

impl Unpin for Buffer

§

impl UnwindSafe for Buffer

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> ToString for T
where T: Display + ?Sized,

Source§

default 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.