about summary refs log tree commit diff
path: root/tests/rustdoc-js/non-english-identifier.rs
blob: 70b5141472c800f048d4469f3f25986914b1d8ba (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
47
#[doc(alias = "加法")]
pub fn add(left: usize, right: usize) -> usize {
    left + right
}

pub fn 中文名称的加法API(left: usize, right: usize) -> usize {
    left + right
}

#[macro_export]
macro_rules! 中文名称的加法宏 {
    ($left:expr, $right:expr) => {
        ($left) + ($right)
    };
}

#[doc(alias = "加法")]
#[macro_export]
macro_rules! add {
    ($left:expr, $right:expr) => {
        ($left) + ($right)
    };
}

/// Add
pub trait 加法<类型> {
    type 结果;
    fn 加上(self, 被加数: 类型) -> Self::结果;
}

/// IntoIterator
pub trait 可迭代 {
    type ;
    type 转为迭代器: Iterator<Item = Self::>;
    fn 迭代(self) -> Self::转为迭代器;
}

pub type 可选<类型> = Option<类型>;

/// "sum"
pub fn 总计<集合, 个体>(容器: 集合) -> 可选<集合::>
where
    集合: 可迭代< = 个体>,
    个体: 加法<个体, 结果 = 个体>,
{
    容器.迭代().reduce(|累计值, 当前值| 累计值.加上(当前值))
}