Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
83203452
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,发现更多精彩内容 >>
提交
83203452
编写于
9月 15, 2015
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #28268 - petrochenkov:fnptr, r=alexcrichton
Closes
https://github.com/rust-lang/rust/issues/26082
上级
a7b3eed7
bc7c4304
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
71 addition
and
69 deletion
+71
-69
src/libcore/clone.rs
src/libcore/clone.rs
+0
-42
src/libcore/ptr.rs
src/libcore/ptr.rs
+71
-27
未找到文件。
src/libcore/clone.rs
浏览文件 @
83203452
...
...
@@ -86,45 +86,3 @@ fn clone(&self) -> $t { *self }
clone_impl!
{
()
}
clone_impl!
{
bool
}
clone_impl!
{
char
}
macro_rules!
extern_fn_clone
{
(
$
(
$A:ident
),
*
)
=>
(
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$A
,)
*
ReturnType
>
Clone
for
extern
"Rust"
fn
(
$
(
$A
),
*
)
->
ReturnType
{
/// Returns a copy of a function pointer.
#[inline]
fn
clone
(
&
self
)
->
extern
"Rust"
fn
(
$
(
$A
),
*
)
->
ReturnType
{
*
self
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$A
,)
*
ReturnType
>
Clone
for
extern
"C"
fn
(
$
(
$A
),
*
)
->
ReturnType
{
/// Returns a copy of a function pointer.
#[inline]
fn
clone
(
&
self
)
->
extern
"C"
fn
(
$
(
$A
),
*
)
->
ReturnType
{
*
self
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$A
,)
*
ReturnType
>
Clone
for
unsafe
extern
"Rust"
fn
(
$
(
$A
),
*
)
->
ReturnType
{
/// Returns a copy of a function pointer.
#[inline]
fn
clone
(
&
self
)
->
unsafe
extern
"Rust"
fn
(
$
(
$A
),
*
)
->
ReturnType
{
*
self
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$A
,)
*
ReturnType
>
Clone
for
unsafe
extern
"C"
fn
(
$
(
$A
),
*
)
->
ReturnType
{
/// Returns a copy of a function pointer.
#[inline]
fn
clone
(
&
self
)
->
unsafe
extern
"C"
fn
(
$
(
$A
),
*
)
->
ReturnType
{
*
self
}
}
)
}
extern_fn_clone!
{}
extern_fn_clone!
{
A
}
extern_fn_clone!
{
A
,
B
}
extern_fn_clone!
{
A
,
B
,
C
}
extern_fn_clone!
{
A
,
B
,
C
,
D
}
extern_fn_clone!
{
A
,
B
,
C
,
D
,
E
}
extern_fn_clone!
{
A
,
B
,
C
,
D
,
E
,
F
}
extern_fn_clone!
{
A
,
B
,
C
,
D
,
E
,
F
,
G
}
extern_fn_clone!
{
A
,
B
,
C
,
D
,
E
,
F
,
G
,
H
}
src/libcore/ptr.rs
浏览文件 @
83203452
...
...
@@ -20,6 +20,7 @@
use
intrinsics
;
use
ops
::
Deref
;
use
fmt
;
use
hash
;
use
option
::
Option
::{
self
,
Some
,
None
};
use
marker
::{
PhantomData
,
Send
,
Sized
,
Sync
};
use
mem
;
...
...
@@ -308,40 +309,83 @@ fn clone(&self) -> *mut T {
}
}
// Equality for extern "C" fn pointers
mod
externfnpointers
{
use
cmp
::
PartialEq
;
// Impls for function pointers
macro_rules!
fnptr_impls_safety_abi
{
(
$FnTy
:
ty
,
$
(
$Arg
:
ident
),
*
)
=>
{
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
Ret
,
$
(
$Arg
),
*>
Clone
for
$FnTy
{
#[inline]
fn
clone
(
&
self
)
->
Self
{
*
self
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
_
R
>
PartialEq
for
extern
"C"
fn
()
->
_
R
{
#[inline]
fn
eq
(
&
self
,
other
:
&
extern
"C"
fn
()
->
_
R
)
->
bool
{
let
self_
=
*
self
as
usize
;
let
other_
=
*
other
as
usize
;
self_
==
other_
#[stable(feature
=
"fnptr_impls"
,
since
=
"1.4.0"
)]
impl
<
Ret
,
$
(
$Arg
),
*>
PartialEq
for
$FnTy
{
#[inline]
fn
eq
(
&
self
,
other
:
&
Self
)
->
bool
{
*
self
as
usize
==
*
other
as
usize
}
}
}
macro_rules!
fnptreq
{
(
$
(
$p:ident
),
*
)
=>
{
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
_
R
,
$
(
$p
),
*>
PartialEq
for
extern
"C"
fn
(
$
(
$p
),
*
)
->
_
R
{
#[inline]
fn
eq
(
&
self
,
other
:
&
extern
"C"
fn
(
$
(
$p
),
*
)
->
_
R
)
->
bool
{
let
self_
=
*
self
as
usize
;
let
other_
=
*
other
as
usize
;
self_
==
other_
}
#[stable(feature
=
"fnptr_impls"
,
since
=
"1.4.0"
)]
impl
<
Ret
,
$
(
$Arg
),
*>
Eq
for
$FnTy
{}
#[stable(feature
=
"fnptr_impls"
,
since
=
"1.4.0"
)]
impl
<
Ret
,
$
(
$Arg
),
*>
PartialOrd
for
$FnTy
{
#[inline]
fn
partial_cmp
(
&
self
,
other
:
&
Self
)
->
Option
<
Ordering
>
{
(
*
self
as
usize
)
.partial_cmp
(
&
(
*
other
as
usize
))
}
}
#[stable(feature
=
"fnptr_impls"
,
since
=
"1.4.0"
)]
impl
<
Ret
,
$
(
$Arg
),
*>
Ord
for
$FnTy
{
#[inline]
fn
cmp
(
&
self
,
other
:
&
Self
)
->
Ordering
{
(
*
self
as
usize
)
.cmp
(
&
(
*
other
as
usize
))
}
}
#[stable(feature
=
"fnptr_impls"
,
since
=
"1.4.0"
)]
impl
<
Ret
,
$
(
$Arg
),
*>
hash
::
Hash
for
$FnTy
{
fn
hash
<
HH
:
hash
::
Hasher
>
(
&
self
,
state
:
&
mut
HH
)
{
state
.write_usize
(
*
self
as
usize
)
}
}
#[stable(feature
=
"fnptr_impls"
,
since
=
"1.4.0"
)]
impl
<
Ret
,
$
(
$Arg
),
*>
fmt
::
Pointer
for
$FnTy
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
fmt
::
Pointer
::
fmt
(
&
(
*
self
as
*
const
()),
f
)
}
}
#[stable(feature
=
"fnptr_impls"
,
since
=
"1.4.0"
)]
impl
<
Ret
,
$
(
$Arg
),
*>
fmt
::
Debug
for
$FnTy
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
fmt
::
Pointer
::
fmt
(
&
(
*
self
as
*
const
()),
f
)
}
}
}
fnptreq!
{
A
}
fnptreq!
{
A
,
B
}
fnptreq!
{
A
,
B
,
C
}
fnptreq!
{
A
,
B
,
C
,
D
}
fnptreq!
{
A
,
B
,
C
,
D
,
E
}
}
macro_rules!
fnptr_impls_args
{
(
$
(
$Arg
:
ident
),
*
)
=>
{
fnptr_impls_safety_abi!
{
extern
"Rust"
fn
(
$
(
$Arg
),
*
)
->
Ret
,
$
(
$Arg
),
*
}
fnptr_impls_safety_abi!
{
extern
"C"
fn
(
$
(
$Arg
),
*
)
->
Ret
,
$
(
$Arg
),
*
}
fnptr_impls_safety_abi!
{
unsafe
extern
"Rust"
fn
(
$
(
$Arg
),
*
)
->
Ret
,
$
(
$Arg
),
*
}
fnptr_impls_safety_abi!
{
unsafe
extern
"C"
fn
(
$
(
$Arg
),
*
)
->
Ret
,
$
(
$Arg
),
*
}
}
}
fnptr_impls_args!
{
}
fnptr_impls_args!
{
A
}
fnptr_impls_args!
{
A
,
B
}
fnptr_impls_args!
{
A
,
B
,
C
}
fnptr_impls_args!
{
A
,
B
,
C
,
D
}
fnptr_impls_args!
{
A
,
B
,
C
,
D
,
E
}
// Comparison for pointers
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
?
Sized
>
Ord
for
*
const
T
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录