Instead of using a depth counter and adding "../" to get to the top,
this commit makes rustdoc actually compare the path of what it's
linking from to the path that it's linking to. This makes the resulting
HTML shorter.
Here's a comparison of one of the largest (non-source) files in the
Rust standard library docs (about 4% improvement before gzipping).
$ wc -c struct.Wrapping.old.html struct.Wrapping.new.html
2387389 struct.Wrapping.old.html
2298538 struct.Wrapping.new.html
Most if it can be efficiently gzipped away.
$ wc -c struct.Wrapping.old.html.gz struct.Wrapping.new.html.gz
70679 struct.Wrapping.old.html.gz
70050 struct.Wrapping.new.html.gz
But it also makes a difference in the final DOM size, reducing it from 91MiB to 82MiB.
31 lines
947 B
Rust
31 lines
947 B
Rust
#![feature(associated_type_defaults)]
|
|
|
|
// @has issue_28478/trait.Bar.html
|
|
pub trait Bar {
|
|
// @has - '//*[@id="associatedtype.Bar"]' 'type Bar = ()'
|
|
// @has - '//*[@href="#associatedtype.Bar"]' 'Bar'
|
|
type Bar = ();
|
|
// @has - '//*[@id="associatedconstant.Baz"]' 'const Baz: usize'
|
|
// @has - '//*[@href="#associatedconstant.Baz"]' 'Baz'
|
|
const Baz: usize = 7;
|
|
// @has - '//*[@id="tymethod.bar"]' 'fn bar'
|
|
fn bar();
|
|
// @has - '//*[@id="method.baz"]' 'fn baz'
|
|
fn baz() { }
|
|
}
|
|
|
|
// @has issue_28478/struct.Foo.html
|
|
pub struct Foo;
|
|
|
|
impl Foo {
|
|
// @has - '//*[@href="#method.foo"]' 'foo'
|
|
pub fn foo() {}
|
|
}
|
|
|
|
impl Bar for Foo {
|
|
// @has - '//*[@href="trait.Bar.html#associatedtype.Bar"]' 'Bar'
|
|
// @has - '//*[@href="trait.Bar.html#associatedconstant.Baz"]' 'Baz'
|
|
// @has - '//*[@href="trait.Bar.html#tymethod.bar"]' 'bar'
|
|
fn bar() {}
|
|
// @has - '//*[@href="trait.Bar.html#method.baz"]' 'baz'
|
|
}
|