rustdoc: print usize with less string manipulation
This commit is contained in:
parent
a69d43493a
commit
e410cd25b2
1 changed files with 6 additions and 12 deletions
|
@ -242,19 +242,13 @@ pub(crate) fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String {
|
||||||
|
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
_ => {
|
// array lengths are obviously usize
|
||||||
let mut s = n.to_string();
|
ty::ConstKind::Value(ty::ValTree::Leaf(scalar))
|
||||||
// array lengths are obviously usize
|
if *n.ty().kind() == ty::Uint(ty::UintTy::Usize) =>
|
||||||
if s.ends_with("_usize") {
|
{
|
||||||
let n = s.len() - "_usize".len();
|
scalar.to_string()
|
||||||
s.truncate(n);
|
|
||||||
if s.ends_with(": ") {
|
|
||||||
let n = s.len() - ": ".len();
|
|
||||||
s.truncate(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s
|
|
||||||
}
|
}
|
||||||
|
_ => n.to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue