Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b258de7b
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,发现更多精彩内容 >>
提交
b258de7b
编写于
11月 20, 2014
作者:
J
Jorge Aparicio
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libcore: add `Rhs` input parameter to comparison traits
上级
3a325c66
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
12 deletion
+13
-12
src/libcore/cmp.rs
src/libcore/cmp.rs
+12
-12
src/libcore/lib.rs
src/libcore/lib.rs
+1
-0
未找到文件。
src/libcore/cmp.rs
浏览文件 @
b258de7b
...
...
@@ -61,13 +61,13 @@
/// `Eq`.
#[lang=
"eq"
]
#[unstable
=
"Definition may change slightly after trait reform"
]
pub
trait
PartialEq
for
Sized
?
{
pub
trait
PartialEq
<
Sized
?
Rhs
=
Self
>
for
Sized
?
{
/// This method tests for `self` and `other` values to be equal, and is used by `==`.
fn
eq
(
&
self
,
other
:
&
Self
)
->
bool
;
fn
eq
(
&
self
,
other
:
&
Rhs
)
->
bool
;
/// This method tests for `!=`.
#[inline]
fn
ne
(
&
self
,
other
:
&
Self
)
->
bool
{
!
self
.eq
(
other
)
}
fn
ne
(
&
self
,
other
:
&
Rhs
)
->
bool
{
!
self
.eq
(
other
)
}
}
/// Trait for equality comparisons which are [equivalence relations](
...
...
@@ -80,7 +80,7 @@ fn ne(&self, other: &Self) -> bool { !self.eq(other) }
/// - symmetric: `a == b` implies `b == a`; and
/// - transitive: `a == b` and `b == c` implies `a == c`.
#[unstable
=
"Definition may change slightly after trait reform"
]
pub
trait
Eq
for
Sized
?
:
PartialEq
{
pub
trait
Eq
<
Sized
?
Rhs
=
Self
>
for
Sized
?
:
PartialEq
<
Rhs
>
{
// FIXME #13101: this method is used solely by #[deriving] to
// assert that every component of a type implements #[deriving]
// itself, the current deriving infrastructure means doing this
...
...
@@ -150,7 +150,7 @@ pub fn reverse(self) -> Ordering {
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for
/// both `==` and `>`.
#[unstable
=
"Definition may change slightly after trait reform"
]
pub
trait
Ord
for
Sized
?
:
Eq
+
PartialOrd
{
pub
trait
Ord
<
Sized
?
Rhs
=
Self
>
for
Sized
?
:
Eq
<
Rhs
>
+
PartialOrd
<
Rhs
>
{
/// This method returns an ordering between `self` and `other` values.
///
/// By convention, `self.cmp(&other)` returns the ordering matching
...
...
@@ -161,7 +161,7 @@ pub trait Ord for Sized?: Eq + PartialOrd {
/// assert_eq!(10u.cmp(&5), Greater); // because 10 > 5
/// assert_eq!( 5u.cmp(&5), Equal); // because 5 == 5
/// ```
fn
cmp
(
&
self
,
other
:
&
Self
)
->
Ordering
;
fn
cmp
(
&
self
,
other
:
&
Rhs
)
->
Ordering
;
}
#[unstable
=
"Trait is unstable."
]
...
...
@@ -194,14 +194,14 @@ fn partial_cmp(&self, other: &Ordering) -> Option<Ordering> {
/// 5.11).
#[lang=
"ord"
]
#[unstable
=
"Definition may change slightly after trait reform"
]
pub
trait
PartialOrd
for
Sized
?
:
PartialEq
{
pub
trait
PartialOrd
<
Sized
?
Rhs
=
Self
>
for
Sized
?
:
PartialEq
<
Rhs
>
{
/// This method returns an ordering between `self` and `other` values
/// if one exists.
fn
partial_cmp
(
&
self
,
other
:
&
Self
)
->
Option
<
Ordering
>
;
fn
partial_cmp
(
&
self
,
other
:
&
Rhs
)
->
Option
<
Ordering
>
;
/// This method tests less than (for `self` and `other`) and is used by the `<` operator.
#[inline]
fn
lt
(
&
self
,
other
:
&
Self
)
->
bool
{
fn
lt
(
&
self
,
other
:
&
Rhs
)
->
bool
{
match
self
.partial_cmp
(
other
)
{
Some
(
Less
)
=>
true
,
_
=>
false
,
...
...
@@ -210,7 +210,7 @@ fn lt(&self, other: &Self) -> bool {
/// This method tests less than or equal to (`<=`).
#[inline]
fn
le
(
&
self
,
other
:
&
Self
)
->
bool
{
fn
le
(
&
self
,
other
:
&
Rhs
)
->
bool
{
match
self
.partial_cmp
(
other
)
{
Some
(
Less
)
|
Some
(
Equal
)
=>
true
,
_
=>
false
,
...
...
@@ -219,7 +219,7 @@ fn le(&self, other: &Self) -> bool {
/// This method tests greater than (`>`).
#[inline]
fn
gt
(
&
self
,
other
:
&
Self
)
->
bool
{
fn
gt
(
&
self
,
other
:
&
Rhs
)
->
bool
{
match
self
.partial_cmp
(
other
)
{
Some
(
Greater
)
=>
true
,
_
=>
false
,
...
...
@@ -228,7 +228,7 @@ fn gt(&self, other: &Self) -> bool {
/// This method tests greater than or equal to (`>=`).
#[inline]
fn
ge
(
&
self
,
other
:
&
Self
)
->
bool
{
fn
ge
(
&
self
,
other
:
&
Rhs
)
->
bool
{
match
self
.partial_cmp
(
other
)
{
Some
(
Greater
)
|
Some
(
Equal
)
=>
true
,
_
=>
false
,
...
...
src/libcore/lib.rs
浏览文件 @
b258de7b
...
...
@@ -59,6 +59,7 @@
#![allow(unknown_features)]
#![feature(globs,
intrinsics,
lang_items,
macro_rules,
phase)]
#![feature(simd,
unsafe_destructor,
slicing_syntax)]
#![feature(default_type_params)]
#![deny(missing_docs)]
mod
macros
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录