rustdoc: print usize with less string manipulation
This commit is contained in:
@@ -242,19 +242,13 @@ pub(crate) fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String {
|
|||||||
|
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
let mut s = n.to_string();
|
|
||||||
// array lengths are obviously usize
|
// array lengths are obviously usize
|
||||||
if s.ends_with("_usize") {
|
ty::ConstKind::Value(ty::ValTree::Leaf(scalar))
|
||||||
let n = s.len() - "_usize".len();
|
if *n.ty().kind() == ty::Uint(ty::UintTy::Usize) =>
|
||||||
s.truncate(n);
|
{
|
||||||
if s.ends_with(": ") {
|
scalar.to_string()
|
||||||
let n = s.len() - ": ".len();
|
|
||||||
s.truncate(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s
|
|
||||||
}
|
}
|
||||||
|
_ => n.to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user