libstd: Implement StrBuf, a new string buffer type like Vec, and
port all code over to use it.
This commit is contained in:
committed by
Huon Wilson
parent
7fbcb400f0
commit
d8e45ea7c0
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user