summary refs log tree commit diff
path: root/src/test/rustdoc/assoc-consts.rs
blob: 04709407e58a89cbf2b93d1c80ff741be15cd24e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(associated_consts)]

pub trait Foo {
    // @has assoc_consts/trait.Foo.html '//*[@class="rust trait"]' \
    //      'const FOO: usize;'
    // @has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize'
    // @has - '//*[@class="docblock"]' 'FOO: usize = 12'
    const FOO: usize = 12;
}

pub struct Bar;

impl Bar {
    // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \
    //      'const BAR: usize'
    // @has - '//*[@class="docblock"]' 'BAR: usize = 3'
    pub const BAR: usize = 3;
}

pub struct Baz<'a, U: 'a, T>(T, &'a [U]);

impl Bar {
    // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \
    //      "const BAZ: Baz<'static, u8, u32>"
    // @has - '//*[@class="docblock"]' "BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3])"
    pub const BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3]);
}

pub fn f(_: &(ToString + 'static)) {}

impl Bar {
    // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \
    //      "const F: fn(_: &(ToString + 'static))"
    // @has - '//*[@class="docblock"]' "F: fn(_: &(ToString + 'static)) = f"
    pub const F: fn(_: &(ToString + 'static)) = f;
}