Clean up API and small fixes
This commit is contained in:
parent
665cdb2881
commit
a80da338e4
13 changed files with 56 additions and 36 deletions
|
|
@ -90,7 +90,7 @@ impl V {
|
|||
let offset = isize::try_from(max_d).expect("max_d must fit in isize");
|
||||
Self {
|
||||
offset,
|
||||
v: vec![0; 2 * max_d],
|
||||
v: vec![0; 2 * max_d + 1],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use std::{fmt, iter::Iterator};
|
||||
use std::{fmt, str::Chars};
|
||||
|
||||
/// A helper for building a string sequentially from an original string via
|
||||
/// insertions, deletions, and copies. All operations use character counts,
|
||||
/// safe for UTF-8. Methods must be called in-order.
|
||||
pub struct StringBuilder<'a> {
|
||||
original: Box<dyn Iterator<Item = char> + 'a>,
|
||||
original: Chars<'a>,
|
||||
buffer: String,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
|
|
@ -26,7 +26,7 @@ impl fmt::Debug for StringBuilder<'_> {
|
|||
impl StringBuilder<'_> {
|
||||
pub fn new(original: &str) -> StringBuilder<'_> {
|
||||
StringBuilder {
|
||||
original: Box::new(original.chars()),
|
||||
original: original.chars(),
|
||||
buffer: String::with_capacity(original.len()),
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue