Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e4a0b480
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e4a0b480
编写于
11月 16, 2015
作者:
S
Steve Klabnik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make note about traits that can be derived
in their API docs Fixes #29711
上级
57c8a3e8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
18 addition
and
0 deletion
+18
-0
src/libcore/clone.rs
src/libcore/clone.rs
+2
-0
src/libcore/cmp.rs
src/libcore/cmp.rs
+8
-0
src/libcore/fmt/mod.rs
src/libcore/fmt/mod.rs
+2
-0
src/libcore/hash/mod.rs
src/libcore/hash/mod.rs
+2
-0
src/libcore/marker.rs
src/libcore/marker.rs
+4
-0
未找到文件。
src/libcore/clone.rs
浏览文件 @
e4a0b480
...
...
@@ -24,6 +24,8 @@
use
marker
::
Sized
;
/// A common trait for cloning an object.
///
/// This trait can be used with `#[derive]`.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
trait
Clone
:
Sized
{
/// Returns a copy of the value.
...
...
src/libcore/cmp.rs
浏览文件 @
e4a0b480
...
...
@@ -43,6 +43,8 @@
/// in terms of it by default. Any manual implementation of `ne` *must* respect
/// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and
/// only if `a != b`.
///
/// This trait can be used with `#[derive]`.
#[lang
=
"eq"
]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
trait
PartialEq
<
Rhs
:
?
Sized
=
Self
>
{
...
...
@@ -69,6 +71,8 @@ fn ne(&self, other: &Rhs) -> bool { !self.eq(other) }
///
/// This property cannot be checked by the compiler, and therefore `Eq` implies
/// `PartialEq`, and has no extra methods.
///
/// This trait can be used with `#[derive]`.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
trait
Eq
:
PartialEq
<
Self
>
{
// FIXME #13101: this method is used solely by #[deriving] to
...
...
@@ -171,6 +175,8 @@ pub fn reverse(self) -> Ordering {
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
///
/// When this trait is `derive`d, it produces a lexicographic ordering.
///
/// This trait can be used with `#[derive]`.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
trait
Ord
:
Eq
+
PartialOrd
<
Self
>
{
/// This method returns an `Ordering` between `self` and `other`.
...
...
@@ -227,6 +233,8 @@ fn partial_cmp(&self, other: &Ordering) -> Option<Ordering> {
/// However it remains possible to implement the others separately for types which do not have a
/// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 ==
/// false` (cf. IEEE 754-2008 section 5.11).
///
/// This trait can be used with `#[derive]`.
#[lang
=
"ord"
]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
trait
PartialOrd
<
Rhs
:
?
Sized
=
Self
>
:
PartialEq
<
Rhs
>
{
...
...
src/libcore/fmt/mod.rs
浏览文件 @
e4a0b480
...
...
@@ -300,6 +300,8 @@ fn fmt(&self, fmt: &mut Formatter) -> Result {
///
/// [module]: ../../std/fmt/index.html
///
/// This trait can be used with `#[derive]`.
///
/// # Examples
///
/// Deriving an implementation:
...
...
src/libcore/hash/mod.rs
浏览文件 @
e4a0b480
...
...
@@ -93,6 +93,8 @@
///
/// In other words, if two keys are equal, their hashes should also be equal.
/// `HashMap` and `HashSet` both rely on this behavior.
///
/// This trait can be used with `#[derive]`.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
trait
Hash
{
/// Feeds this value into the state given, updating the hasher as necessary.
...
...
src/libcore/marker.rs
浏览文件 @
e4a0b480
...
...
@@ -165,6 +165,10 @@ pub trait Unsize<T: ?Sized> {
/// to consider though: if you think your type may _not_ be able to implement `Copy` in the future,
/// then it might be prudent to not implement `Copy`. This is because removing `Copy` is a breaking
/// change: that second example would fail to compile if we made `Foo` non-`Copy`.
///
/// # Derivable
///
/// This trait can be used with `#[derive]`.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
#[lang
=
"copy"
]
pub
trait
Copy
:
Clone
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录