{
stability
}
-fn item_constant(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
- c: &clean::Constant) -> fmt::Result {
- write!(w, "")?;
- render_attributes(w, it, false)?;
+fn item_constant(w: &mut Buffer, cx: &Context, it: &clean::Item, c: &clean::Constant) {
+ write!(w, "");
+ render_attributes(w, it, false);
write!(w, "{vis}const \
{name}: {typ}",
vis = VisSpace(&it.visibility),
name = it.name.as_ref().unwrap(),
- typ = c.type_)?;
+ typ = c.type_);
document(w, cx, it)
}
-fn item_static(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
- s: &clean::Static) -> fmt::Result {
- write!(w, "")?;
- render_attributes(w, it, false)?;
+fn item_static(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Static) {
+ write!(w, "");
+ render_attributes(w, it, false);
write!(w, "{vis}static {mutability}\
{name}: {typ}",
vis = VisSpace(&it.visibility),
mutability = MutableSpace(s.mutability),
name = it.name.as_ref().unwrap(),
- typ = s.type_)?;
+ typ = s.type_);
document(w, cx, it)
}
-fn item_function(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
- f: &clean::Function) -> fmt::Result {
+fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Function) {
let header_len = format!(
"{}{}{}{}{:#}fn {}{:#}",
VisSpace(&it.visibility),
@@ -2836,8 +2821,8 @@ fn item_function(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
it.name.as_ref().unwrap(),
f.generics
).len();
- write!(w, "{}", render_spotlight_traits(it)?)?;
- render_attributes(w, it, false)?;
+ write!(w, "{}", render_spotlight_traits(it));
+ render_attributes(w, it, false);
write!(w,
"{vis}{constness}{unsafety}{asyncness}{abi}fn \
{name}{generics}{decl}{where_clause}",
@@ -2854,12 +2839,12 @@ fn item_function(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
header_len,
indent: 0,
asyncness: f.header.asyncness,
- })?;
+ });
document(w, cx, it)
}
-fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter<'_>,
- implementor_dups: &FxHashMap<&str, (DefId, bool)>) -> fmt::Result {
+fn render_implementor(cx: &Context, implementor: &Impl, w: &mut Buffer,
+ implementor_dups: &FxHashMap<&str, (DefId, bool)>) {
// If there's already another implementor that has the same abbridged name, use the
// full path, for example in `std::iter::ExactSizeIterator`
let use_absolute = match implementor.inner_impl().for_ {
@@ -2871,20 +2856,18 @@ fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter<'
_ => false,
};
render_impl(w, cx, implementor, AssocItemLink::Anchor(None), RenderMode::Normal,
- implementor.impl_item.stable_since(), false, Some(use_absolute), false, false)?;
- Ok(())
+ implementor.impl_item.stable_since(), false, Some(use_absolute), false, false);
}
-fn render_impls(cx: &Context, w: &mut fmt::Formatter<'_>,
+fn render_impls(cx: &Context, w: &mut Buffer,
traits: &[&&Impl],
- containing_item: &clean::Item) -> fmt::Result {
+ containing_item: &clean::Item) {
for i in traits {
let did = i.trait_did().unwrap();
let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods);
render_impl(w, cx, i, assoc_link,
- RenderMode::Normal, containing_item.stable_since(), true, None, false, true)?;
+ RenderMode::Normal, containing_item.stable_since(), true, None, false, true);
}
- Ok(())
}
fn bounds(t_bounds: &[clean::GenericBound], trait_alias: bool) -> String {
@@ -2912,11 +2895,11 @@ fn compare_impl<'a, 'b>(lhs: &'a &&Impl, rhs: &'b &&Impl) -> Ordering {
}
fn item_trait(
- w: &mut fmt::Formatter<'_>,
+ w: &mut Buffer,
cx: &Context,
it: &clean::Item,
t: &clean::Trait,
-) -> fmt::Result {
+) {
let bounds = bounds(&t.bounds, false);
let types = t.items.iter().filter(|m| m.is_associated_type()).collect::>();
let consts = t.items.iter().filter(|m| m.is_associated_const()).collect::>();
@@ -2925,146 +2908,144 @@ fn item_trait(
// Output the trait definition
wrap_into_docblock(w, |w| {
- write!(w, "")?;
- render_attributes(w, it, true)?;
+ write!(w, "");
+ render_attributes(w, it, true);
write!(w, "{}{}{}trait {}{}{}",
VisSpace(&it.visibility),
UnsafetySpace(t.unsafety),
if t.is_auto { "auto " } else { "" },
it.name.as_ref().unwrap(),
t.generics,
- bounds)?;
+ bounds);
if !t.generics.where_predicates.is_empty() {
- write!(w, "{}", WhereClause { gens: &t.generics, indent: 0, end_newline: true })?;
+ write!(w, "{}", WhereClause { gens: &t.generics, indent: 0, end_newline: true });
} else {
- write!(w, " ")?;
+ write!(w, " ");
}
if t.items.is_empty() {
- write!(w, "{{ }}")?;
+ write!(w, "{{ }}");
} else {
// FIXME: we should be using a derived_id for the Anchors here
- write!(w, "{{\n")?;
+ write!(w, "{{\n");
for t in &types {
- render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait)?;
- write!(w, ";\n")?;
+ render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait);
+ write!(w, ";\n");
}
if !types.is_empty() && !consts.is_empty() {
- w.write_str("\n")?;
+ w.write_str("\n");
}
for t in &consts {
- render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait)?;
- write!(w, ";\n")?;
+ render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait);
+ write!(w, ";\n");
}
if !consts.is_empty() && !required.is_empty() {
- w.write_str("\n")?;
+ w.write_str("\n");
}
for (pos, m) in required.iter().enumerate() {
- render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait)?;
- write!(w, ";\n")?;
+ render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait);
+ write!(w, ";\n");
if pos < required.len() - 1 {
- write!(w, "")?;
+ write!(w, "");
}
}
if !required.is_empty() && !provided.is_empty() {
- w.write_str("\n")?;
+ w.write_str("\n");
}
for (pos, m) in provided.iter().enumerate() {
- render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait)?;
+ render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait);
match m.inner {
clean::MethodItem(ref inner) if !inner.generics.where_predicates.is_empty() => {
- write!(w, ",\n {{ ... }}\n")?;
+ write!(w, ",\n {{ ... }}\n");
},
_ => {
- write!(w, " {{ ... }}\n")?;
+ write!(w, " {{ ... }}\n");
},
}
if pos < provided.len() - 1 {
- write!(w, "")?;
+ write!(w, "");
}
}
- write!(w, "}}")?;
+ write!(w, "}}");
}
write!(w, "")
- })?;
+ });
// Trait documentation
- document(w, cx, it)?;
+ document(w, cx, it);
fn write_small_section_header(
- w: &mut fmt::Formatter<'_>,
+ w: &mut Buffer,
id: &str,
title: &str,
extra_content: &str,
- ) -> fmt::Result {
+ ) {
write!(w, "
{2}", id, title, extra_content)
}
- fn write_loading_content(w: &mut fmt::Formatter<'_>, extra_content: &str) -> fmt::Result {
+ fn write_loading_content(w: &mut Buffer, extra_content: &str) {
write!(w, "{}Loading content...", extra_content)
}
- fn trait_item(w: &mut fmt::Formatter<'_>, cx: &Context, m: &clean::Item, t: &clean::Item)
- -> fmt::Result {
+ fn trait_item(w: &mut Buffer, cx: &Context, m: &clean::Item, t: &clean::Item) {
let name = m.name.as_ref().unwrap();
let item_type = m.type_();
let id = cx.derive_id(format!("{}.{}", item_type, name));
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
write!(w, "{extra}",
- extra = render_spotlight_traits(m)?,
+ extra = render_spotlight_traits(m),
id = id,
- ns_id = ns_id)?;
- render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl)?;
- write!(w, "")?;
- render_stability_since(w, m, t)?;
- write!(w, "
")?;
- document(w, cx, m)?;
- Ok(())
+ ns_id = ns_id);
+ render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl);
+ write!(w, "");
+ render_stability_since(w, m, t);
+ write!(w, "");
+ document(w, cx, m);
}
if !types.is_empty() {
write_small_section_header(w, "associated-types", "Associated Types",
- "")?;
+ "
");
for t in &types {
- trait_item(w, cx, *t, it)?;
+ trait_item(w, cx, *t, it);
}
- write_loading_content(w, "
")?;
+ write_loading_content(w, "
");
}
if !consts.is_empty() {
write_small_section_header(w, "associated-const", "Associated Constants",
- "")?;
+ "
");
for t in &consts {
- trait_item(w, cx, *t, it)?;
+ trait_item(w, cx, *t, it);
}
- write_loading_content(w, "
")?;
+ write_loading_content(w, "
");
}
// Output the documentation for each function individually
if !required.is_empty() {
write_small_section_header(w, "required-methods", "Required methods",
- "")?;
+ "
");
for m in &required {
- trait_item(w, cx, *m, it)?;
+ trait_item(w, cx, *m, it);
}
- write_loading_content(w, "
")?;
+ write_loading_content(w, "
");
}
if !provided.is_empty() {
write_small_section_header(w, "provided-methods", "Provided methods",
- "")?;
+ "
");
for m in &provided {
- trait_item(w, cx, *m, it)?;
+ trait_item(w, cx, *m, it);
}
- write_loading_content(w, "
")?;
+ write_loading_content(w, "
");
}
// If there are methods directly on this trait object, render them here.
- render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)?;
+ render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All);
let cache = cache();
@@ -3103,7 +3084,7 @@ fn item_trait(
concrete.sort_by(compare_impl);
if !foreign.is_empty() {
- write_small_section_header(w, "foreign-impls", "Implementations on Foreign Types", "")?;
+ write_small_section_header(w, "foreign-impls", "Implementations on Foreign Types", "");
for implementor in foreign {
let assoc_link = AssocItemLink::GotoSource(
@@ -3112,44 +3093,44 @@ fn item_trait(
);
render_impl(w, cx, &implementor, assoc_link,
RenderMode::Normal, implementor.impl_item.stable_since(), false,
- None, true, false)?;
+ None, true, false);
}
- write_loading_content(w, "")?;
+ write_loading_content(w, "");
}
write_small_section_header(w, "implementors", "Implementors",
- "")?;
+ "
");
for implementor in concrete {
- render_implementor(cx, implementor, w, &implementor_dups)?;
+ render_implementor(cx, implementor, w, &implementor_dups);
}
- write_loading_content(w, "
")?;
+ write_loading_content(w, "
");
if t.auto {
write_small_section_header(w, "synthetic-implementors", "Auto implementors",
- "")?;
+ "
");
for implementor in synthetic {
synthetic_types.extend(
collect_paths_for_type(implementor.inner_impl().for_.clone())
);
- render_implementor(cx, implementor, w, &implementor_dups)?;
+ render_implementor(cx, implementor, w, &implementor_dups);
}
- write_loading_content(w, "
")?;
+ write_loading_content(w, "
");
}
} else {
// even without any implementations to write in, we still want the heading and list, so the
// implementors javascript file pulled in below has somewhere to write the impls into
write_small_section_header(w, "implementors", "Implementors",
- "")?;
- write_loading_content(w, "
")?;
+ "");
+ write_loading_content(w, "
");
if t.auto {
write_small_section_header(w, "synthetic-implementors", "Auto implementors",
- "")?;
- write_loading_content(w, "
")?;
+ "");
+ write_loading_content(w, "
");
}
}
write!(w, r#""#,
- as_json(&synthetic_types))?;
+ as_json(&synthetic_types));
write!(w, r#"