Rollup merge of #85957 - BoxyUwU:rustdoc-const-generic-defaults, r=oli-obk
Display defaults on const params- rustdoc previously rustdoc would render this struct declaration: `pub struct Foo<const N: usize = 10>;` as: `pub struct Foo<const N: usize>;` this PR changes it to render correctly
This commit is contained in:
commit
606feba5bb
8 changed files with 39 additions and 10 deletions
|
|
@ -177,12 +177,22 @@ impl clean::GenericParamDef {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
clean::GenericParamDefKind::Const { ref ty, .. } => {
|
||||
clean::GenericParamDefKind::Const { ref ty, ref default, .. } => {
|
||||
if f.alternate() {
|
||||
write!(f, "const {}: {:#}", self.name, ty.print(cx))
|
||||
write!(f, "const {}: {:#}", self.name, ty.print(cx))?;
|
||||
} else {
|
||||
write!(f, "const {}: {}", self.name, ty.print(cx))
|
||||
write!(f, "const {}: {}", self.name, ty.print(cx))?;
|
||||
}
|
||||
|
||||
if let Some(default) = default {
|
||||
if f.alternate() {
|
||||
write!(f, " = {:#}", default)?;
|
||||
} else {
|
||||
write!(f, " = {}", default)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue