pub struct MagicString<'s> {
    pub filename: Option<String>,
    /* private fields */
}

Fields§

§filename: Option<String>

Implementations§

source§

impl<'text> MagicString<'text>

source

pub fn update( &mut self, start: impl AssertIntoU32, end: impl AssertIntoU32, content: impl Into<BasicCowStr<'text>> ) -> &mut Self

A shorthand for update_with(start, end, content, Default::default());

source

pub fn update_with( &mut self, start: impl AssertIntoU32, end: impl AssertIntoU32, content: impl Into<BasicCowStr<'text>>, opts: UpdateOptions ) -> &mut Self

source

pub fn remove( &mut self, start: impl AssertIntoU32, end: impl AssertIntoU32 ) -> &mut Self

source

pub fn relocate( &mut self, start: impl AssertIntoU32, end: impl AssertIntoU32, to: impl AssertIntoU32 ) -> &mut Self

Moves the characters from start and end to index. Returns this.

source§

impl<'text> MagicString<'text>

source

pub fn new(source: impl Into<BasicCowStr<'text>>) -> Self

source

pub fn with_options( source: impl Into<BasicCowStr<'text>>, options: MagicStringOptions ) -> Self

source

pub fn append(&mut self, source: impl Into<BasicCowStr<'text>>) -> &mut Self

source

pub fn append_left( &mut self, text_index: impl AssertIntoU32, content: impl Into<BasicCowStr<'text>> ) -> &mut Self

Example
 use string_wizard::MagicString;
 let mut s = MagicString::new("01234");
 s.append_left(2, "a");
 s.append_left(2, "b");
 assert_eq!(s.to_string(), "01ab234")
source

pub fn append_right( &mut self, text_index: impl AssertIntoU32, content: impl Into<BasicCowStr<'text>> ) -> &mut Self

Example
use string_wizard::MagicString;
let mut s = MagicString::new("01234");
s.append_right(2, "A");
s.append_right(2, "B");
s.append_left(2, "a");
s.append_left(2, "b");
assert_eq!(s.to_string(), "01abAB234")
source

pub fn prepend(&mut self, source: impl Into<BasicCowStr<'text>>) -> &mut Self

source

pub fn prepend_left( &mut self, text_index: impl AssertIntoU32, content: impl Into<BasicCowStr<'text>> ) -> &mut Self

source

pub fn prepend_right( &mut self, text_index: impl AssertIntoU32, content: impl Into<BasicCowStr<'text>> ) -> &mut Self

source

pub fn len(&self) -> usize

source

pub fn to_string(&self) -> String

Trait Implementations§

source§

impl<'s> Clone for MagicString<'s>

source§

fn clone(&self) -> MagicString<'s>

Returns a copy 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<'s> Debug for MagicString<'s>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s> RefUnwindSafe for MagicString<'s>

§

impl<'s> Send for MagicString<'s>

§

impl<'s> Sync for MagicString<'s>

§

impl<'s> Unpin for MagicString<'s>

§

impl<'s> UnwindSafe for MagicString<'s>

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> ToOwned for T
where T: Clone,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.