libstd: Implement StrBuf, a new string buffer type like Vec, and

port all code over to use it.
This commit is contained in:
Patrick Walton
2014-04-02 16:54:22 -07:00
committed by Huon Wilson
parent 7fbcb400f0
commit d8e45ea7c0
66 changed files with 990 additions and 931 deletions

View File

@@ -11,6 +11,7 @@
//! Table-of-contents creation.
use std::fmt;
use std::strbuf::StrBuf;
/// A (recursive) table of contents
#[deriving(Eq)]
@@ -136,11 +137,11 @@ impl TocBuilder {
{
let (toc_level, toc) = match self.chain.last() {
None => {
sec_number = ~"";
sec_number = StrBuf::new();
(0, &self.top_level)
}
Some(entry) => {
sec_number = entry.sec_number.clone();
sec_number = StrBuf::from_str(entry.sec_number.clone());
sec_number.push_str(".");
(entry.level, &entry.children)
}
@@ -156,12 +157,12 @@ impl TocBuilder {
}
self.chain.push(TocEntry {
level: level,
name: name,
sec_number: sec_number,
id: id,
children: Toc { entries: Vec::new() }
});
level: level,
name: name,
sec_number: sec_number.into_owned(),
id: id,
children: Toc { entries: Vec::new() }
});
// get the thing we just pushed, so we can borrow the string
// out of it with the right lifetime