Struct string_wizard::MagicString
source · pub struct MagicString<'s> {
pub filename: Option<String>,
/* private fields */
}
Fields§
§filename: Option<String>
Implementations§
source§impl<'text> MagicString<'text>
impl<'text> MagicString<'text>
sourcepub fn update(
&mut self,
start: impl AssertIntoU32,
end: impl AssertIntoU32,
content: impl Into<BasicCowStr<'text>>
) -> &mut Self
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())
;
pub fn update_with( &mut self, start: impl AssertIntoU32, end: impl AssertIntoU32, content: impl Into<BasicCowStr<'text>>, opts: UpdateOptions ) -> &mut Self
pub fn remove( &mut self, start: impl AssertIntoU32, end: impl AssertIntoU32 ) -> &mut Self
source§impl<'text> MagicString<'text>
impl<'text> MagicString<'text>
pub fn new(source: impl Into<BasicCowStr<'text>>) -> Self
pub fn with_options( source: impl Into<BasicCowStr<'text>>, options: MagicStringOptions ) -> Self
pub fn append(&mut self, source: impl Into<BasicCowStr<'text>>) -> &mut Self
sourcepub fn append_left(
&mut self,
text_index: impl AssertIntoU32,
content: impl Into<BasicCowStr<'text>>
) -> &mut Self
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")
sourcepub fn append_right(
&mut self,
text_index: impl AssertIntoU32,
content: impl Into<BasicCowStr<'text>>
) -> &mut Self
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")
pub fn prepend(&mut self, source: impl Into<BasicCowStr<'text>>) -> &mut Self
pub fn prepend_left( &mut self, text_index: impl AssertIntoU32, content: impl Into<BasicCowStr<'text>> ) -> &mut Self
pub fn prepend_right( &mut self, text_index: impl AssertIntoU32, content: impl Into<BasicCowStr<'text>> ) -> &mut Self
pub fn len(&self) -> usize
pub fn to_string(&self) -> String
Trait Implementations§
source§impl<'s> Clone for MagicString<'s>
impl<'s> Clone for MagicString<'s>
source§fn clone(&self) -> MagicString<'s>
fn clone(&self) -> MagicString<'s>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more