Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1772fa2a
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,发现更多精彩内容 >>
提交
1772fa2a
编写于
12月 22, 2017
作者:
S
Simon Sapin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename Box::*_nonnull_raw to *_non_null_raw
上级
55c50cd8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
18 addition
and
18 deletion
+18
-18
src/liballoc/arc.rs
src/liballoc/arc.rs
+2
-2
src/liballoc/boxed.rs
src/liballoc/boxed.rs
+11
-11
src/liballoc/linked_list.rs
src/liballoc/linked_list.rs
+3
-3
src/liballoc/rc.rs
src/liballoc/rc.rs
+2
-2
未找到文件。
src/liballoc/arc.rs
浏览文件 @
1772fa2a
...
...
@@ -286,7 +286,7 @@ pub fn new(data: T) -> Arc<T> {
weak
:
atomic
::
AtomicUsize
::
new
(
1
),
data
,
};
Arc
{
ptr
:
Box
::
into_nonnull_raw
(
x
),
phantom
:
PhantomData
}
Arc
{
ptr
:
Box
::
into_non
_
null_raw
(
x
),
phantom
:
PhantomData
}
}
/// Returns the contained value, if the `Arc` has exactly one strong reference.
...
...
@@ -991,7 +991,7 @@ impl<T> Weak<T> {
pub
fn
new
()
->
Weak
<
T
>
{
unsafe
{
Weak
{
ptr
:
Box
::
into_nonnull_raw
(
box
ArcInner
{
ptr
:
Box
::
into_non
_
null_raw
(
box
ArcInner
{
strong
:
atomic
::
AtomicUsize
::
new
(
0
),
weak
:
atomic
::
AtomicUsize
::
new
(
1
),
data
:
uninitialized
(),
...
...
src/liballoc/boxed.rs
浏览文件 @
1772fa2a
...
...
@@ -290,13 +290,13 @@ pub unsafe fn from_raw(raw: *mut T) -> Self {
/// ```
/// fn main() {
/// let x = Box::new(5);
/// let ptr = Box::into_nonnull_raw(x);
/// let x = unsafe { Box::from_nonnull_raw(ptr) };
/// let ptr = Box::into_non
_
null_raw(x);
/// let x = unsafe { Box::from_non
_
null_raw(ptr) };
/// }
/// ```
#[stable(feature
=
"nonnull"
,
since
=
"1.24.0"
)]
#[inline]
pub
unsafe
fn
from_nonnull_raw
(
u
:
NonNull
<
T
>
)
->
Self
{
pub
unsafe
fn
from_non
_
null_raw
(
u
:
NonNull
<
T
>
)
->
Self
{
Box
(
u
.into
())
}
...
...
@@ -323,7 +323,7 @@ pub unsafe fn from_nonnull_raw(u: NonNull<T>) -> Self {
#[stable(feature
=
"box_raw"
,
since
=
"1.4.0"
)]
#[inline]
pub
fn
into_raw
(
b
:
Box
<
T
>
)
->
*
mut
T
{
Box
::
into_nonnull_raw
(
b
)
.as_ptr
()
Box
::
into_non
_
null_raw
(
b
)
.as_ptr
()
}
/// Consumes the `Box`, returning the wrapped pointer as `NonNull<T>`.
...
...
@@ -333,17 +333,17 @@ pub fn into_raw(b: Box<T>) -> *mut T {
/// caller should properly destroy `T` and release the memory. The
/// proper way to do so is to either convert the `NonNull<T>` pointer:
///
/// - Into a `Box` with the [`Box::from_nonnull_raw`] function.
/// - Into a `Box` with the [`Box::from_non
_
null_raw`] function.
///
/// - Into a raw pointer and back into a `Box` with the [`Box::from_raw`]
/// function.
///
/// Note: this is an associated function, which means that you have
/// to call it as `Box::into_nonnull_raw(b)`
/// instead of `b.into_nonnull_raw()`. This
/// to call it as `Box::into_non
_
null_raw(b)`
/// instead of `b.into_non
_
null_raw()`. This
/// is so that there is no conflict with a method on the inner type.
///
/// [`Box::from_non
null_raw`]: struct.Box.html#method.from_non
null_raw
/// [`Box::from_non
_null_raw`]: struct.Box.html#method.from_non_
null_raw
/// [`Box::from_raw`]: struct.Box.html#method.from_raw
///
/// # Examples
...
...
@@ -351,16 +351,16 @@ pub fn into_raw(b: Box<T>) -> *mut T {
/// ```
/// fn main() {
/// let x = Box::new(5);
/// let ptr = Box::into_nonnull_raw(x);
/// let ptr = Box::into_non
_
null_raw(x);
/// }
/// ```
#[stable(feature
=
"nonnull"
,
since
=
"1.24.0"
)]
#[inline]
pub
fn
into_nonnull_raw
(
b
:
Box
<
T
>
)
->
NonNull
<
T
>
{
pub
fn
into_non
_
null_raw
(
b
:
Box
<
T
>
)
->
NonNull
<
T
>
{
Box
::
into_unique
(
b
)
.into
()
}
#[unstable(feature
=
"ptr_internals"
,
issue
=
"0"
,
reason
=
"use into_nonnull_raw instead"
)]
#[unstable(feature
=
"ptr_internals"
,
issue
=
"0"
,
reason
=
"use into_non
_
null_raw instead"
)]
#[inline]
pub
fn
into_unique
(
b
:
Box
<
T
>
)
->
Unique
<
T
>
{
let
unique
=
b
.0
;
...
...
src/liballoc/linked_list.rs
浏览文件 @
1772fa2a
...
...
@@ -157,7 +157,7 @@ fn push_front_node(&mut self, mut node: Box<Node<T>>) {
unsafe
{
node
.next
=
self
.head
;
node
.prev
=
None
;
let
node
=
Some
(
Box
::
into_nonnull_raw
(
node
));
let
node
=
Some
(
Box
::
into_non
_
null_raw
(
node
));
match
self
.head
{
None
=>
self
.tail
=
node
,
...
...
@@ -192,7 +192,7 @@ fn push_back_node(&mut self, mut node: Box<Node<T>>) {
unsafe
{
node
.next
=
None
;
node
.prev
=
self
.tail
;
let
node
=
Some
(
Box
::
into_nonnull_raw
(
node
));
let
node
=
Some
(
Box
::
into_non
_
null_raw
(
node
));
match
self
.tail
{
None
=>
self
.head
=
node
,
...
...
@@ -986,7 +986,7 @@ pub fn insert_next(&mut self, element: T) {
Some
(
prev
)
=>
prev
,
};
let
node
=
Some
(
Box
::
into_nonnull_raw
(
box
Node
{
let
node
=
Some
(
Box
::
into_non
_
null_raw
(
box
Node
{
next
:
Some
(
head
),
prev
:
Some
(
prev
),
element
,
...
...
src/liballoc/rc.rs
浏览文件 @
1772fa2a
...
...
@@ -311,7 +311,7 @@ pub fn new(value: T) -> Rc<T> {
// pointers, which ensures that the weak destructor never frees
// the allocation while the strong destructor is running, even
// if the weak pointer is stored inside the strong one.
ptr
:
Box
::
into_nonnull_raw
(
box
RcBox
{
ptr
:
Box
::
into_non
_
null_raw
(
box
RcBox
{
strong
:
Cell
::
new
(
1
),
weak
:
Cell
::
new
(
1
),
value
,
...
...
@@ -1190,7 +1190,7 @@ impl<T> Weak<T> {
pub
fn
new
()
->
Weak
<
T
>
{
unsafe
{
Weak
{
ptr
:
Box
::
into_nonnull_raw
(
box
RcBox
{
ptr
:
Box
::
into_non
_
null_raw
(
box
RcBox
{
strong
:
Cell
::
new
(
0
),
weak
:
Cell
::
new
(
1
),
value
:
uninitialized
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录