1
Fork 0

rustdoc: clean up primitive.slice.html links

This commit is contained in:
Michael Howell 2022-06-02 14:28:18 -07:00
parent e71440575c
commit 7dd3861235
6 changed files with 48 additions and 22 deletions

View file

@ -881,11 +881,16 @@ fn fmt_type<'cx>(
} }
} }
} }
clean::Slice(ref t) => { clean::Slice(ref t) => match **t {
primitive_link(f, PrimitiveType::Slice, "[", cx)?; clean::Generic(name) => {
fmt::Display::fmt(&t.print(cx), f)?; primitive_link(f, PrimitiveType::Slice, &format!("[{name}]"), cx)
primitive_link(f, PrimitiveType::Slice, "]", cx) }
} _ => {
primitive_link(f, PrimitiveType::Slice, "[", cx)?;
fmt::Display::fmt(&t.print(cx), f)?;
primitive_link(f, PrimitiveType::Slice, "]", cx)
}
},
clean::Array(ref t, ref n) => { clean::Array(ref t, ref n) => {
primitive_link(f, PrimitiveType::Array, "[", cx)?; primitive_link(f, PrimitiveType::Array, "[", cx)?;
fmt::Display::fmt(&t.print(cx), f)?; fmt::Display::fmt(&t.print(cx), f)?;
@ -924,23 +929,12 @@ fn fmt_type<'cx>(
clean::Slice(ref bt) => { clean::Slice(ref bt) => {
// `BorrowedRef{ ... Slice(T) }` is `&[T]` // `BorrowedRef{ ... Slice(T) }` is `&[T]`
match **bt { match **bt {
clean::Generic(_) => { clean::Generic(name) => primitive_link(
if f.alternate() { f,
primitive_link( PrimitiveType::Slice,
f, &format!("{amp}{lt}{m}[{name}]"),
PrimitiveType::Slice, cx,
&format!("{}{}{}[{:#}]", amp, lt, m, bt.print(cx)), ),
cx,
)
} else {
primitive_link(
f,
PrimitiveType::Slice,
&format!("{}{}{}[{}]", amp, lt, m, bt.print(cx)),
cx,
)
}
}
_ => { _ => {
primitive_link( primitive_link(
f, f,

View file

@ -0,0 +1 @@
<code>pub fn delta&lt;T&gt;() -&gt; <a class="struct" href="struct.MyBox.html" title="struct foo::MyBox">MyBox</a>&lt;<a class="primitive" href="{{channel}}/core/primitive.slice.html">[T]</a>&gt;</code>

View file

@ -0,0 +1 @@
<code>pub fn gamma() -&gt; <a class="struct" href="struct.MyBox.html" title="struct foo::MyBox">MyBox</a>&lt;<a class="primitive" href="{{channel}}/core/primitive.slice.html">[</a><a class="primitive" href="{{channel}}/core/primitive.u32.html">u32</a><a class="primitive" href="{{channel}}/core/primitive.slice.html">]</a>&gt;</code>

View file

@ -0,0 +1 @@
<code>pub fn beta&lt;T&gt;() -&gt; <a class="primitive" href="{{channel}}/core/primitive.slice.html">&amp;'static [T]</a></code>

View file

@ -0,0 +1 @@
<code>pub fn alpha() -&gt; <a class="primitive" href="{{channel}}/core/primitive.slice.html">&amp;'static [</a><a class="primitive" href="{{channel}}/core/primitive.u32.html">u32</a><a class="primitive" href="{{channel}}/core/primitive.slice.html">]</a></code>

View file

@ -0,0 +1,28 @@
#![crate_name = "foo"]
#![no_std]
pub struct MyBox<T: ?Sized>(*const T);
// @has 'foo/fn.alpha.html'
// @snapshot link_slice_u32 - '//pre[@class="rust fn"]/code'
pub fn alpha() -> &'static [u32] {
loop {}
}
// @has 'foo/fn.beta.html'
// @snapshot link_slice_generic - '//pre[@class="rust fn"]/code'
pub fn beta<T>() -> &'static [T] {
loop {}
}
// @has 'foo/fn.gamma.html'
// @snapshot link_box_u32 - '//pre[@class="rust fn"]/code'
pub fn gamma() -> MyBox<[u32]> {
loop {}
}
// @has 'foo/fn.delta.html'
// @snapshot link_box_generic - '//pre[@class="rust fn"]/code'
pub fn delta<T>() -> MyBox<[T]> {
loop {}
}