Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9b3dfd8e
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,发现更多精彩内容 >>
提交
9b3dfd8e
编写于
4月 24, 2020
作者:
J
Joe Richey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: Make pointer offset methods "const fn"
Signed-off-by:
N
Joe Richey
<
joerichey@google.com
>
上级
08df3116
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
12 deletion
+27
-12
src/libcore/intrinsics.rs
src/libcore/intrinsics.rs
+2
-0
src/libcore/lib.rs
src/libcore/lib.rs
+1
-0
src/libcore/ptr/const_ptr.rs
src/libcore/ptr/const_ptr.rs
+12
-6
src/libcore/ptr/mut_ptr.rs
src/libcore/ptr/mut_ptr.rs
+12
-6
未找到文件。
src/libcore/intrinsics.rs
浏览文件 @
9b3dfd8e
...
...
@@ -1314,6 +1314,7 @@
/// The stabilized version of this intrinsic is
/// [`std::pointer::offset`](../../std/primitive.pointer.html#method.offset).
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
pub
fn
offset
<
T
>
(
dst
:
*
const
T
,
offset
:
isize
)
->
*
const
T
;
/// Calculates the offset from a pointer, potentially wrapping.
...
...
@@ -1331,6 +1332,7 @@
/// The stabilized version of this intrinsic is
/// [`std::pointer::wrapping_offset`](../../std/primitive.pointer.html#method.wrapping_offset).
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
pub
fn
arith_offset
<
T
>
(
dst
:
*
const
T
,
offset
:
isize
)
->
*
const
T
;
/// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
...
...
src/libcore/lib.rs
浏览文件 @
9b3dfd8e
...
...
@@ -85,6 +85,7 @@
#![feature(const_panic)]
#![feature(const_fn_union)]
#![feature(const_generics)]
#![feature(const_ptr_offset)]
#![feature(const_ptr_offset_from)]
#![feature(const_result)]
#![feature(const_slice_from_raw_parts)]
...
...
src/libcore/ptr/const_ptr.rs
浏览文件 @
9b3dfd8e
...
...
@@ -151,8 +151,9 @@ pub unsafe fn as_ref<'a>(self) -> Option<&'a T> {
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
unsafe
fn
offset
(
self
,
count
:
isize
)
->
*
const
T
pub
const
unsafe
fn
offset
(
self
,
count
:
isize
)
->
*
const
T
where
T
:
Sized
,
{
...
...
@@ -210,8 +211,9 @@ pub unsafe fn offset(self, count: isize) -> *const T
/// ```
#[stable(feature
=
"ptr_wrapping_offset"
,
since
=
"1.16.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
fn
wrapping_offset
(
self
,
count
:
isize
)
->
*
const
T
pub
const
fn
wrapping_offset
(
self
,
count
:
isize
)
->
*
const
T
where
T
:
Sized
,
{
...
...
@@ -393,8 +395,9 @@ pub fn wrapping_offset_from(self, origin: *const T) -> isize
/// ```
#[stable(feature
=
"pointer_methods"
,
since
=
"1.26.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
unsafe
fn
add
(
self
,
count
:
usize
)
->
Self
pub
const
unsafe
fn
add
(
self
,
count
:
usize
)
->
Self
where
T
:
Sized
,
{
...
...
@@ -455,8 +458,9 @@ pub unsafe fn add(self, count: usize) -> Self
/// ```
#[stable(feature
=
"pointer_methods"
,
since
=
"1.26.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
unsafe
fn
sub
(
self
,
count
:
usize
)
->
Self
pub
const
unsafe
fn
sub
(
self
,
count
:
usize
)
->
Self
where
T
:
Sized
,
{
...
...
@@ -511,8 +515,9 @@ pub unsafe fn sub(self, count: usize) -> Self
/// ```
#[stable(feature
=
"pointer_methods"
,
since
=
"1.26.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
fn
wrapping_add
(
self
,
count
:
usize
)
->
Self
pub
const
fn
wrapping_add
(
self
,
count
:
usize
)
->
Self
where
T
:
Sized
,
{
...
...
@@ -567,8 +572,9 @@ pub fn wrapping_add(self, count: usize) -> Self
/// ```
#[stable(feature
=
"pointer_methods"
,
since
=
"1.26.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
fn
wrapping_sub
(
self
,
count
:
usize
)
->
Self
pub
const
fn
wrapping_sub
(
self
,
count
:
usize
)
->
Self
where
T
:
Sized
,
{
...
...
src/libcore/ptr/mut_ptr.rs
浏览文件 @
9b3dfd8e
...
...
@@ -145,8 +145,9 @@ pub unsafe fn as_ref<'a>(self) -> Option<&'a T> {
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
unsafe
fn
offset
(
self
,
count
:
isize
)
->
*
mut
T
pub
const
unsafe
fn
offset
(
self
,
count
:
isize
)
->
*
mut
T
where
T
:
Sized
,
{
...
...
@@ -203,8 +204,9 @@ pub unsafe fn offset(self, count: isize) -> *mut T
/// ```
#[stable(feature
=
"ptr_wrapping_offset"
,
since
=
"1.16.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
fn
wrapping_offset
(
self
,
count
:
isize
)
->
*
mut
T
pub
const
fn
wrapping_offset
(
self
,
count
:
isize
)
->
*
mut
T
where
T
:
Sized
,
{
...
...
@@ -439,8 +441,9 @@ pub fn wrapping_offset_from(self, origin: *const T) -> isize
/// ```
#[stable(feature
=
"pointer_methods"
,
since
=
"1.26.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
unsafe
fn
add
(
self
,
count
:
usize
)
->
Self
pub
const
unsafe
fn
add
(
self
,
count
:
usize
)
->
Self
where
T
:
Sized
,
{
...
...
@@ -501,8 +504,9 @@ pub unsafe fn add(self, count: usize) -> Self
/// ```
#[stable(feature
=
"pointer_methods"
,
since
=
"1.26.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
unsafe
fn
sub
(
self
,
count
:
usize
)
->
Self
pub
const
unsafe
fn
sub
(
self
,
count
:
usize
)
->
Self
where
T
:
Sized
,
{
...
...
@@ -557,8 +561,9 @@ pub unsafe fn sub(self, count: usize) -> Self
/// ```
#[stable(feature
=
"pointer_methods"
,
since
=
"1.26.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
fn
wrapping_add
(
self
,
count
:
usize
)
->
Self
pub
const
fn
wrapping_add
(
self
,
count
:
usize
)
->
Self
where
T
:
Sized
,
{
...
...
@@ -613,8 +618,9 @@ pub fn wrapping_add(self, count: usize) -> Self
/// ```
#[stable(feature
=
"pointer_methods"
,
since
=
"1.26.0"
)]
#[must_use
=
"returns a new pointer rather than modifying its argument"
]
#[rustc_const_unstable(feature
=
"const_ptr_offset"
,
issue
=
"71499"
)]
#[inline]
pub
fn
wrapping_sub
(
self
,
count
:
usize
)
->
Self
pub
const
fn
wrapping_sub
(
self
,
count
:
usize
)
->
Self
where
T
:
Sized
,
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录