Struct RefactoryString

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

A RefactoryBuffer specialization that only accepts and returns UTF-8 strings. This is what should be used when modifying a source string/file content. It uses RefactoryBuffer and converts everything conveniently.

Implementations§

Source§

impl<'a> RefactoryString<'a>

Source

pub fn new(content: &'a str) -> RefactoryString<'a>

Create a new RefactoryString from the content. Never owns the original content, but owns every changes made to it.

Source

pub fn len(&self) -> usize

The original length of the content it contains.

Source

pub fn to_string(&self) -> String

Serialize the changes to a string.

Source

pub fn append_left(&mut self, index: usize, content: &str) -> Result<(), Error>

Append the content to the left of the index.

Source

pub fn prepend_left(&mut self, index: usize, content: &str) -> Result<(), Error>

Prepend the content to the left of the index.

Source

pub fn append_right(&mut self, index: usize, content: &str) -> Result<(), Error>

Append the content to the right of the index.

Source

pub fn prepend_right( &mut self, index: usize, content: &str, ) -> Result<(), Error>

Prepend the content to the right of the index.

Source

pub fn prepend(&mut self, content: &str) -> Result<(), Error>

Prepend the content to the whole RefactoryString.

Source

pub fn append(&mut self, content: &str) -> Result<(), Error>

Append the content to the whole RefactoryString.

Source

pub fn overwrite( &mut self, start: usize, end: usize, content: &str, ) -> Result<(), Error>

Overwrite the content at the indices [start, end].

Source

pub fn remove(&mut self, start: usize, end: usize) -> Result<(), Error>

Remove the content between two indices.

Auto Trait Implementations§

§

impl<'a> Freeze for RefactoryString<'a>

§

impl<'a> RefUnwindSafe for RefactoryString<'a>

§

impl<'a> Send for RefactoryString<'a>

§

impl<'a> Sync for RefactoryString<'a>

§

impl<'a> Unpin for RefactoryString<'a>

§

impl<'a> UnwindSafe for RefactoryString<'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 = 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.