librustdoc: Remove all ~str
usage from librustdoc.
This commit is contained in:
parent
6559a3675e
commit
9ba91e1243
13 changed files with 357 additions and 261 deletions
|
@ -39,9 +39,9 @@ impl Toc {
|
|||
#[deriving(Eq)]
|
||||
pub struct TocEntry {
|
||||
level: u32,
|
||||
sec_number: ~str,
|
||||
name: ~str,
|
||||
id: ~str,
|
||||
sec_number: StrBuf,
|
||||
name: StrBuf,
|
||||
id: StrBuf,
|
||||
children: Toc,
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ impl TocBuilder {
|
|||
/// Push a level `level` heading into the appropriate place in the
|
||||
/// heirarchy, returning a string containing the section number in
|
||||
/// `<num>.<num>.<num>` format.
|
||||
pub fn push<'a>(&'a mut self, level: u32, name: ~str, id: ~str) -> &'a str {
|
||||
pub fn push<'a>(&'a mut self, level: u32, name: StrBuf, id: StrBuf) -> &'a str {
|
||||
assert!(level >= 1);
|
||||
|
||||
// collapse all previous sections into their parents until we
|
||||
|
@ -141,7 +141,8 @@ impl TocBuilder {
|
|||
(0, &self.top_level)
|
||||
}
|
||||
Some(entry) => {
|
||||
sec_number = StrBuf::from_str(entry.sec_number.clone());
|
||||
sec_number = StrBuf::from_str(entry.sec_number
|
||||
.as_slice());
|
||||
sec_number.push_str(".");
|
||||
(entry.level, &entry.children)
|
||||
}
|
||||
|
@ -153,13 +154,13 @@ impl TocBuilder {
|
|||
sec_number.push_str("0.");
|
||||
}
|
||||
let number = toc.count_entries_with_level(level);
|
||||
sec_number.push_str(format!("{}", number + 1))
|
||||
sec_number.push_str(format_strbuf!("{}", number + 1).as_slice())
|
||||
}
|
||||
|
||||
self.chain.push(TocEntry {
|
||||
level: level,
|
||||
name: name,
|
||||
sec_number: sec_number.into_owned(),
|
||||
sec_number: sec_number,
|
||||
id: id,
|
||||
children: Toc { entries: Vec::new() }
|
||||
});
|
||||
|
@ -200,7 +201,10 @@ mod test {
|
|||
// there's been no macro mistake.
|
||||
macro_rules! push {
|
||||
($level: expr, $name: expr) => {
|
||||
assert_eq!(builder.push($level, $name.to_owned(), "".to_owned()), $name);
|
||||
assert_eq!(builder.push($level,
|
||||
$name.to_strbuf(),
|
||||
"".to_strbuf()),
|
||||
$name);
|
||||
}
|
||||
}
|
||||
push!(2, "0.1");
|
||||
|
@ -238,9 +242,9 @@ mod test {
|
|||
$(
|
||||
TocEntry {
|
||||
level: $level,
|
||||
name: $name.to_owned(),
|
||||
sec_number: $name.to_owned(),
|
||||
id: "".to_owned(),
|
||||
name: $name.to_strbuf(),
|
||||
sec_number: $name.to_strbuf(),
|
||||
id: "".to_strbuf(),
|
||||
children: toc!($($sub),*)
|
||||
}
|
||||
),*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue