Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
94e42c2d
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,发现更多精彩内容 >>
提交
94e42c2d
编写于
7月 11, 2014
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
collections: Make push_back/pop_back default methods
上级
2d79bfa4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
38 deletion
+18
-38
src/libcollections/dlist.rs
src/libcollections/dlist.rs
+4
-16
src/libcollections/lib.rs
src/libcollections/lib.rs
+2
-2
src/libcollections/ringbuf.rs
src/libcollections/ringbuf.rs
+12
-20
未找到文件。
src/libcollections/dlist.rs
浏览文件 @
94e42c2d
...
...
@@ -249,29 +249,17 @@ fn push_front(&mut self, elt: T) {
fn
pop_front
(
&
mut
self
)
->
Option
<
T
>
{
self
.pop_front_node
()
.map
(|
box
Node
{
value
,
..
}|
value
)
}
}
/// Add an element last in the list
///
/// O(1)
#[deprecated
=
"use the `push` method"
]
fn
push_back
(
&
mut
self
,
elt
:
T
)
{
impl
<
T
>
MutableSeq
<
T
>
for
DList
<
T
>
{
fn
push
(
&
mut
self
,
elt
:
T
)
{
self
.push_back_node
(
box
Node
::
new
(
elt
))
}
/// Remove the last element and return it, or None if the list is empty
///
/// O(1)
#[deprecated
=
"use the `pop` method"
]
fn
pop_back
(
&
mut
self
)
->
Option
<
T
>
{
fn
pop
(
&
mut
self
)
->
Option
<
T
>
{
self
.pop_back_node
()
.map
(|
box
Node
{
value
,
..
}|
value
)
}
}
impl
<
T
>
MutableSeq
<
T
>
for
DList
<
T
>
{
fn
push
(
&
mut
self
,
elt
:
T
)
{
self
.push_back
(
elt
)
}
fn
pop
(
&
mut
self
)
->
Option
<
T
>
{
self
.pop_back
()
}
}
impl
<
T
>
Default
for
DList
<
T
>
{
#[inline]
fn
default
()
->
DList
<
T
>
{
DList
::
new
()
}
...
...
src/libcollections/lib.rs
浏览文件 @
94e42c2d
...
...
@@ -516,7 +516,7 @@ pub trait Deque<T> : MutableSeq<T> {
/// assert_eq!(d.front(), Some(&1i));
/// ```
#[deprecated
=
"use the `push` method"
]
fn
push_back
(
&
mut
self
,
elt
:
T
)
;
fn
push_back
(
&
mut
self
,
elt
:
T
)
{
self
.push
(
elt
)
}
/// Remove the last element and return it, or `None` if the sequence is empty.
///
...
...
@@ -534,7 +534,7 @@ pub trait Deque<T> : MutableSeq<T> {
/// assert_eq!(d.pop_back(), None);
/// ```
#[deprecated
=
"use the `pop` method"
]
fn
pop_back
(
&
mut
self
)
->
Option
<
T
>
;
fn
pop_back
(
&
mut
self
)
->
Option
<
T
>
{
self
.pop
()
}
/// Remove the first element and return it, or `None` if the sequence is empty.
///
...
...
src/libcollections/ringbuf.rs
浏览文件 @
94e42c2d
...
...
@@ -80,18 +80,6 @@ fn pop_front(&mut self) -> Option<T> {
result
}
/// Remove and return the last element in the RingBuf, or None if it is empty
#[deprecated
=
"use the `pop` method"
]
fn
pop_back
(
&
mut
self
)
->
Option
<
T
>
{
if
self
.nelts
>
0
{
self
.nelts
-=
1
;
let
hi
=
self
.raw_index
(
self
.nelts
);
self
.elts
.get_mut
(
hi
)
.take
()
}
else
{
None
}
}
/// Prepend an element to the RingBuf
fn
push_front
(
&
mut
self
,
t
:
T
)
{
if
self
.nelts
==
self
.elts
.len
()
{
...
...
@@ -103,10 +91,10 @@ fn push_front(&mut self, t: T) {
*
self
.elts
.get_mut
(
self
.lo
)
=
Some
(
t
);
self
.nelts
+=
1u
;
}
}
/// Append an element to the RingBuf
#[deprecated
=
"use the `push` method"
]
fn
push_back
(
&
mut
self
,
t
:
T
)
{
impl
<
T
>
MutableSeq
<
T
>
for
RingBuf
<
T
>
{
fn
push
(
&
mut
self
,
t
:
T
)
{
if
self
.nelts
==
self
.elts
.len
()
{
grow
(
self
.nelts
,
&
mut
self
.lo
,
&
mut
self
.elts
);
}
...
...
@@ -114,11 +102,15 @@ fn push_back(&mut self, t: T) {
*
self
.elts
.get_mut
(
hi
)
=
Some
(
t
);
self
.nelts
+=
1u
;
}
}
impl
<
T
>
MutableSeq
<
T
>
for
RingBuf
<
T
>
{
fn
push
(
&
mut
self
,
t
:
T
)
{
self
.push_back
(
t
)
}
fn
pop
(
&
mut
self
)
->
Option
<
T
>
{
self
.pop_back
()
}
fn
pop
(
&
mut
self
)
->
Option
<
T
>
{
if
self
.nelts
>
0
{
self
.nelts
-=
1
;
let
hi
=
self
.raw_index
(
self
.nelts
);
self
.elts
.get_mut
(
hi
)
.take
()
}
else
{
None
}
}
}
impl
<
T
>
Default
for
RingBuf
<
T
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录