#offset #string #times #original #multiple #splice

multisplice

easily splice a string multiple times, using offsets into the original string

3 releases (breaking)

0.3.0 Oct 19, 2019
0.2.0 Oct 19, 2019
0.1.0 Jul 24, 2019

#43 in #times

Apache-2.0

10KB
113 lines

multisplice

easily splice a string multiple times, using offsets into the original string

crates travis docs

Install

In Cargo.toml:

[dependencies]
multisplice = "^0.3.0"

API

See docs.rs.

License

Apache-2.0


lib.rs:

Easily splice a string multiple times, using offsets into the original string. This way you don't have to track offsets after making a change, which can get hairy very quickly!

Usage

use multisplice::Multisplice;

let source = "a b c d e";
let mut splicer = Multisplice::new(source);
// static string
splicer.splice(2, 3, "beep");
// owned string
splicer.splice(6, 7, "boop".to_string());
assert_eq!(splicer.to_string(), "a beep c boop e");
assert_eq!(splicer.slice_range((3..7)), " c boop");

No runtime deps