pub struct Replacer<'a> { /* private fields */ }Expand description
Replacer replaces a list of slices with replacements. It is safe for concurrent use by multiple goroutines.
zh-cn
Replacer类型进行一系列字节切片的替换。Implementations§
Source§impl<'a> Replacer<'a>
impl<'a> Replacer<'a>
Sourcepub fn new(pairs: Vec<(&'a [byte], &'a [byte])>) -> Replacer<'a>
pub fn new(pairs: Vec<(&'a [byte], &'a [byte])>) -> Replacer<'a>
new returns a new Replacer from a list of old, new bytes pairs. Replacements are performed in the order they appear in the target string, without overlapping matches. The old string comparisons are done in argument order.
zh-cn
使用提供的多组old、new字节切片对创建并返回一个*Replacer。替换是依次进行的,匹配时不会重叠。§Example
use gostd_bytes as bytes;
let p = vec![("<".as_bytes(), "<".as_bytes()), (">".as_bytes(), ">".as_bytes())];
let r = bytes::Replacer::new(p);
let s = r.Replace("This is <b>HTML</b>!".as_bytes());
println!("{}", String::from_utf8(s).unwrap());
§Output
This is <b>HTML</b>!Auto Trait Implementations§
impl<'a> Freeze for Replacer<'a>
impl<'a> RefUnwindSafe for Replacer<'a>
impl<'a> Send for Replacer<'a>
impl<'a> Sync for Replacer<'a>
impl<'a> Unpin for Replacer<'a>
impl<'a> UnwindSafe for Replacer<'a>
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