rust/tests/rustdoc/intra-doc/self.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

117 lines
2.6 KiB
Rust
Raw Normal View History

2018-07-12 20:00:57 +00:00
#![crate_name = "foo"]
2020-05-22 09:50:22 +00:00
// @has foo/index.html '//a/@href' 'struct.Foo.html#method.new'
// @has foo/struct.Foo.html '//a/@href' 'struct.Foo.html#method.new'
2018-07-12 20:00:57 +00:00
/// Use [`new`] to create a new instance.
///
/// [`new`]: Self::new
pub struct Foo;
impl Foo {
pub fn new() -> Self {
unimplemented!()
}
}
// @has foo/index.html '//a/@href' 'struct.Bar.html#method.new2'
// @has foo/struct.Bar.html '//a/@href' 'struct.Bar.html#method.new2'
2018-07-12 20:00:57 +00:00
/// Use [`new2`] to create a new instance.
///
/// [`new2`]: Self::new2
pub struct Bar;
impl Bar {
pub fn new2() -> Self {
unimplemented!()
}
}
2020-05-22 09:50:22 +00:00
pub struct MyStruct {
// @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#structfield.struct_field'
2020-05-22 09:50:22 +00:00
/// [`struct_field`]
///
/// [`struct_field`]: Self::struct_field
pub struct_field: u8,
}
pub enum MyEnum {
// @has foo/enum.MyEnum.html '//a/@href' 'enum.MyEnum.html#variant.EnumVariant'
2020-05-22 09:50:22 +00:00
/// [`EnumVariant`]
///
/// [`EnumVariant`]: Self::EnumVariant
EnumVariant,
}
pub union MyUnion {
// @has foo/union.MyUnion.html '//a/@href' 'union.MyUnion.html#structfield.union_field'
2020-05-22 09:50:22 +00:00
/// [`union_field`]
///
/// [`union_field`]: Self::union_field
pub union_field: f32,
}
pub trait MyTrait {
// @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedtype.AssoType'
2020-05-22 09:50:22 +00:00
/// [`AssoType`]
///
/// [`AssoType`]: Self::AssoType
type AssoType;
// @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedconstant.ASSO_CONST'
2020-05-22 09:50:22 +00:00
/// [`ASSO_CONST`]
///
/// [`ASSO_CONST`]: Self::ASSO_CONST
const ASSO_CONST: i32 = 1;
// @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#method.asso_fn'
2020-05-22 09:50:22 +00:00
/// [`asso_fn`]
///
/// [`asso_fn`]: Self::asso_fn
fn asso_fn() {}
}
impl MyStruct {
// @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.for_impl'
2020-05-22 09:50:22 +00:00
/// [`for_impl`]
///
/// [`for_impl`]: Self::for_impl
pub fn for_impl() {
unimplemented!()
}
}
impl MyTrait for MyStruct {
// @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedtype.AssoType'
2020-05-22 09:50:22 +00:00
/// [`AssoType`]
///
/// [`AssoType`]: Self::AssoType
type AssoType = u32;
// @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedconstant.ASSO_CONST'
2020-05-22 09:50:22 +00:00
/// [`ASSO_CONST`]
///
/// [`ASSO_CONST`]: Self::ASSO_CONST
const ASSO_CONST: i32 = 10;
// @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.asso_fn'
2020-05-22 09:50:22 +00:00
/// [`asso_fn`]
///
/// [`asso_fn`]: Self::asso_fn
fn asso_fn() {
unimplemented!()
}
}