Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9940ed08
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,发现更多精彩内容 >>
提交
9940ed08
编写于
6月 07, 2022
作者:
M
Michael Howell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs: clean up trait docs for tuples
上级
7fe2c4b0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
132 addition
and
72 deletion
+132
-72
library/core/src/fmt/mod.rs
library/core/src/fmt/mod.rs
+27
-11
library/core/src/hash/mod.rs
library/core/src/hash/mod.rs
+23
-7
library/core/src/tuple.rs
library/core/src/tuple.rs
+82
-54
未找到文件。
library/core/src/fmt/mod.rs
浏览文件 @
9940ed08
...
...
@@ -2313,23 +2313,39 @@ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
macro_rules!
tuple
{
()
=>
();
(
$
(
$name:ident
,)
+
)
=>
(
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$name:Debug
),
+>
Debug
for
(
$
(
$name
,)
+
)
where
last_type!
(
$
(
$name
,)
+
):
?
Sized
{
#[allow(non_snake_case,
unused_assignments)]
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
Result
{
let
mut
builder
=
f
.debug_tuple
(
""
);
let
(
$
(
ref
$name
,)
+
)
=
*
self
;
$
(
builder
.field
(
&
$name
);
)
+
builder
.finish
()
maybe_tuple_doc!
{
$
(
$name
)
+
@
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$name:Debug
),
+>
Debug
for
(
$
(
$name
,)
+
)
where
last_type!
(
$
(
$name
,)
+
):
?
Sized
{
#[allow(non_snake_case,
unused_assignments)]
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
Result
{
let
mut
builder
=
f
.debug_tuple
(
""
);
let
(
$
(
ref
$name
,)
+
)
=
*
self
;
$
(
builder
.field
(
&
$name
);
)
+
builder
.finish
()
}
}
}
peel!
{
$
(
$name
,)
+
}
)
}
macro_rules!
maybe_tuple_doc
{
(
$a:ident
@
#[
$
meta:meta]
$item:item
)
=>
{
#[doc
=
"This trait is implemented for tuples up to twelve items long."
]
#[
$
meta]
$item
};
(
$a:ident
$
(
$rest_a:ident
)
+
@
#[
$
meta:meta]
$item:item
)
=>
{
#[doc(hidden)]
#[
$
meta]
$item
};
}
macro_rules!
last_type
{
(
$a:ident
,)
=>
{
$a
};
(
$a:ident
,
$
(
$rest_a:ident
,)
+
)
=>
{
last_type!
(
$
(
$rest_a
,)
+
)
};
...
...
library/core/src/hash/mod.rs
浏览文件 @
9940ed08
...
...
@@ -883,18 +883,34 @@ fn hash<H: Hasher>(&self, _state: &mut H) {}
);
(
$
(
$name:ident
)
+
)
=>
(
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$name
:
Hash
),
+>
Hash
for
(
$
(
$name
,)
+
)
where
last_type!
(
$
(
$name
,)
+
):
?
Sized
{
#[allow(non_snake_case)]
#[inline]
fn
hash
<
S
:
Hasher
>
(
&
self
,
state
:
&
mut
S
)
{
let
(
$
(
ref
$name
,)
+
)
=
*
self
;
$
(
$name
.hash
(
state
);)
+
maybe_tuple_doc!
{
$
(
$name
)
+
@
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$name
:
Hash
),
+>
Hash
for
(
$
(
$name
,)
+
)
where
last_type!
(
$
(
$name
,)
+
):
?
Sized
{
#[allow(non_snake_case)]
#[inline]
fn
hash
<
S
:
Hasher
>
(
&
self
,
state
:
&
mut
S
)
{
let
(
$
(
ref
$name
,)
+
)
=
*
self
;
$
(
$name
.hash
(
state
);)
+
}
}
}
);
}
macro_rules!
maybe_tuple_doc
{
(
$a:ident
@
#[
$
meta:meta]
$item:item
)
=>
{
#[doc
=
"This trait is implemented for tuples up to twelve items long."
]
#[
$
meta]
$item
};
(
$a:ident
$
(
$rest_a:ident
)
+
@
#[
$
meta:meta]
$item:item
)
=>
{
#[doc(hidden)]
#[
$
meta]
$item
};
}
macro_rules!
last_type
{
(
$a:ident
,)
=>
{
$a
};
(
$a:ident
,
$
(
$rest_a:ident
,)
+
)
=>
{
last_type!
(
$
(
$rest_a
,)
+
)
};
...
...
library/core/src/tuple.rs
浏览文件 @
9940ed08
...
...
@@ -19,75 +19,103 @@
};
// "Private" internal implementation
(
@
impl
$
(
$T:ident
)
+
)
=>
{
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$T:PartialEq
),
+>
PartialEq
for
(
$
(
$T
,)
+
)
where
last_type!
(
$
(
$T
,)
+
):
?
Sized
{
#[inline]
fn
eq
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()}
==
other
.
$
{
index
()}
)
&&+
}
#[inline]
fn
ne
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()}
!=
other
.
$
{
index
()}
)||
+
maybe_tuple_doc!
{
$
(
$T
)
+
@
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$T:PartialEq
),
+>
PartialEq
for
(
$
(
$T
,)
+
)
where
last_type!
(
$
(
$T
,)
+
):
?
Sized
{
#[inline]
fn
eq
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()}
==
other
.
$
{
index
()}
)
&&+
}
#[inline]
fn
ne
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()}
!=
other
.
$
{
index
()}
)||
+
}
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$T:Eq
),
+>
Eq
for
(
$
(
$T
,)
+
)
where
last_type!
(
$
(
$T
,)
+
):
?
Sized
{}
maybe_tuple_doc!
{
$
(
$T
)
+
@
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$T:Eq
),
+>
Eq
for
(
$
(
$T
,)
+
)
where
last_type!
(
$
(
$T
,)
+
):
?
Sized
{}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$T:PartialOrd
+
PartialEq
),
+>
PartialOrd
for
(
$
(
$T
,)
+
)
where
last_type!
(
$
(
$T
,)
+
):
?
Sized
{
#[inline]
fn
partial_cmp
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
Option
<
Ordering
>
{
lexical_partial_cmp!
(
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
}
#[inline]
fn
lt
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
lexical_ord!
(
lt
,
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
}
#[inline]
fn
le
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
lexical_ord!
(
le
,
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
}
#[inline]
fn
ge
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
lexical_ord!
(
ge
,
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
}
#[inline]
fn
gt
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
lexical_ord!
(
gt
,
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
maybe_tuple_doc!
{
$
(
$T
)
+
@
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$T:PartialOrd
+
PartialEq
),
+>
PartialOrd
for
(
$
(
$T
,)
+
)
where
last_type!
(
$
(
$T
,)
+
):
?
Sized
{
#[inline]
fn
partial_cmp
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
Option
<
Ordering
>
{
lexical_partial_cmp!
(
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
}
#[inline]
fn
lt
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
lexical_ord!
(
lt
,
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
}
#[inline]
fn
le
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
lexical_ord!
(
le
,
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
}
#[inline]
fn
ge
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
lexical_ord!
(
ge
,
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
}
#[inline]
fn
gt
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
bool
{
lexical_ord!
(
gt
,
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
}
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$T:Ord
),
+>
Ord
for
(
$
(
$T
,)
+
)
where
last_type!
(
$
(
$T
,)
+
):
?
Sized
{
#[inline]
fn
cmp
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
Ordering
{
lexical_cmp!
(
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
maybe_tuple_doc!
{
$
(
$T
)
+
@
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$T:Ord
),
+>
Ord
for
(
$
(
$T
,)
+
)
where
last_type!
(
$
(
$T
,)
+
):
?
Sized
{
#[inline]
fn
cmp
(
&
self
,
other
:
&
(
$
(
$T
,)
+
))
->
Ordering
{
lexical_cmp!
(
$
(
$
{
ignore
(
T
)}
self
.
$
{
index
()},
other
.
$
{
index
()}
),
+
)
}
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$T:Default
),
+>
Default
for
(
$
(
$T
,)
+
)
{
#[inline]
fn
default
()
->
(
$
(
$T
,)
+
)
{
(
$
({
let
x
:
$T
=
Default
::
default
();
x
},)
+
)
maybe_tuple_doc!
{
$
(
$T
)
+
@
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$T:Default
),
+>
Default
for
(
$
(
$T
,)
+
)
{
#[inline]
fn
default
()
->
(
$
(
$T
,)
+
)
{
(
$
({
let
x
:
$T
=
Default
::
default
();
x
},)
+
)
}
}
}
}
}
macro_rules!
maybe_tuple_doc
{
(
$a:ident
@
#[
$
meta:meta]
$item:item
)
=>
{
#[doc
=
"This trait is implemented for tuples up to twelve items long."
]
#[
$
meta]
$item
};
(
$a:ident
$
(
$rest_a:ident
)
+
@
#[
$
meta:meta]
$item:item
)
=>
{
#[doc(hidden)]
#[
$
meta]
$item
};
}
// Constructs an expression that performs a lexical ordering using method $rel.
// The values are interleaved, so the macro invocation for
// `(a1, a2, a3) < (b1, b2, b3)` would be `lexical_ord!(lt, a1, b1, a2, b2,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录