Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b29c3686
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,发现更多精彩内容 >>
提交
b29c3686
编写于
6月 23, 2013
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removing a lot of usage of '&const'
上级
0326b0ab
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
105 addition
and
137 deletion
+105
-137
src/libextra/arc.rs
src/libextra/arc.rs
+2
-2
src/libextra/bitv.rs
src/libextra/bitv.rs
+2
-2
src/libextra/deque.rs
src/libextra/deque.rs
+2
-2
src/libextra/flate.rs
src/libextra/flate.rs
+4
-4
src/libextra/treemap.rs
src/libextra/treemap.rs
+4
-4
src/librustc/middle/lang_items.rs
src/librustc/middle/lang_items.rs
+38
-38
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+2
-2
src/librustc/middle/typeck/check/vtable.rs
src/librustc/middle/typeck/check/vtable.rs
+1
-1
src/libstd/at_vec.rs
src/libstd/at_vec.rs
+3
-3
src/libstd/hashmap.rs
src/libstd/hashmap.rs
+4
-4
src/libstd/io.rs
src/libstd/io.rs
+3
-3
src/libstd/option.rs
src/libstd/option.rs
+2
-2
src/libstd/ptr.rs
src/libstd/ptr.rs
+9
-9
src/libstd/str.rs
src/libstd/str.rs
+4
-4
src/libstd/task/spawn.rs
src/libstd/task/spawn.rs
+1
-1
src/libstd/trie.rs
src/libstd/trie.rs
+4
-4
src/libstd/vec.rs
src/libstd/vec.rs
+20
-52
未找到文件。
src/libextra/arc.rs
浏览文件 @
b29c3686
...
...
@@ -436,8 +436,8 @@ pub fn downgrade<'a>(&self, token: RWWriteMode<'a, T>)
// lock it. This wraps the unsafety, with the justification that the 'lock'
// field is never overwritten; only 'failed' and 'data'.
#[doc(hidden)]
fn
borrow_rwlock
<
T
:
Freeze
+
Send
>
(
state
:
*
cons
t
RWARCInner
<
T
>
)
->
*
RWlock
{
unsafe
{
cast
::
transmute
(
&
const
(
*
state
)
.lock
)
}
fn
borrow_rwlock
<
T
:
Freeze
+
Send
>
(
state
:
*
mu
t
RWARCInner
<
T
>
)
->
*
RWlock
{
unsafe
{
cast
::
transmute
(
&
(
*
state
)
.lock
)
}
}
/// The "write permission" token used for RWARC.write_downgrade().
...
...
src/libextra/bitv.rs
浏览文件 @
b29c3686
...
...
@@ -705,8 +705,8 @@ fn ne(&self, other: &BitvSet) -> bool { !self.eq(other) }
}
impl
Container
for
BitvSet
{
fn
len
(
&
const
self
)
->
uint
{
self
.size
}
fn
is_empty
(
&
const
self
)
->
bool
{
self
.size
==
0
}
fn
len
(
&
self
)
->
uint
{
self
.size
}
fn
is_empty
(
&
self
)
->
bool
{
self
.size
==
0
}
}
impl
Mutable
for
BitvSet
{
...
...
src/libextra/deque.rs
浏览文件 @
b29c3686
...
...
@@ -28,10 +28,10 @@ pub struct Deque<T> {
impl
<
T
>
Container
for
Deque
<
T
>
{
/// Return the number of elements in the deque
fn
len
(
&
const
self
)
->
uint
{
self
.nelts
}
fn
len
(
&
self
)
->
uint
{
self
.nelts
}
/// Return true if the deque contains no elements
fn
is_empty
(
&
const
self
)
->
bool
{
self
.len
()
==
0
}
fn
is_empty
(
&
self
)
->
bool
{
self
.len
()
==
0
}
}
impl
<
T
>
Mutable
for
Deque
<
T
>
{
...
...
src/libextra/flate.rs
浏览文件 @
b29c3686
...
...
@@ -44,8 +44,8 @@ unsafe fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
static
lz_norm
:
c_int
=
0x80
;
// LZ with 128 probes, "normal"
static
lz_best
:
c_int
=
0xfff
;
// LZ with 4095 probes, "best"
pub
fn
deflate_bytes
(
bytes
:
&
const
[
u8
])
->
~
[
u8
]
{
do
vec
::
as_
const
_buf
(
bytes
)
|
b
,
len
|
{
pub
fn
deflate_bytes
(
bytes
:
&
[
u8
])
->
~
[
u8
]
{
do
vec
::
as_
imm
_buf
(
bytes
)
|
b
,
len
|
{
unsafe
{
let
mut
outsz
:
size_t
=
0
;
let
res
=
...
...
@@ -62,8 +62,8 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
}
}
pub
fn
inflate_bytes
(
bytes
:
&
const
[
u8
])
->
~
[
u8
]
{
do
vec
::
as_
const
_buf
(
bytes
)
|
b
,
len
|
{
pub
fn
inflate_bytes
(
bytes
:
&
[
u8
])
->
~
[
u8
]
{
do
vec
::
as_
imm
_buf
(
bytes
)
|
b
,
len
|
{
unsafe
{
let
mut
outsz
:
size_t
=
0
;
let
res
=
...
...
src/libextra/treemap.rs
浏览文件 @
b29c3686
...
...
@@ -87,10 +87,10 @@ fn gt(&self, other: &TreeMap<K, V>) -> bool { lt(other, self) }
impl
<
K
:
TotalOrd
,
V
>
Container
for
TreeMap
<
K
,
V
>
{
/// Return the number of elements in the map
fn
len
(
&
const
self
)
->
uint
{
self
.length
}
fn
len
(
&
self
)
->
uint
{
self
.length
}
/// Return true if the map contains no elements
fn
is_empty
(
&
const
self
)
->
bool
{
self
.root
.is_none
()
}
fn
is_empty
(
&
self
)
->
bool
{
self
.root
.is_none
()
}
}
impl
<
K
:
TotalOrd
,
V
>
Mutable
for
TreeMap
<
K
,
V
>
{
...
...
@@ -265,11 +265,11 @@ fn gt(&self, other: &TreeSet<T>) -> bool { self.map > other.map }
impl
<
T
:
TotalOrd
>
Container
for
TreeSet
<
T
>
{
/// Return the number of elements in the set
#[inline]
fn
len
(
&
const
self
)
->
uint
{
self
.map
.len
()
}
fn
len
(
&
self
)
->
uint
{
self
.map
.len
()
}
/// Return true if the set contains no elements
#[inline]
fn
is_empty
(
&
const
self
)
->
bool
{
self
.map
.is_empty
()
}
fn
is_empty
(
&
self
)
->
bool
{
self
.map
.is_empty
()
}
}
impl
<
T
:
TotalOrd
>
Mutable
for
TreeSet
<
T
>
{
...
...
src/librustc/middle/lang_items.rs
浏览文件 @
b29c3686
...
...
@@ -152,122 +152,122 @@ pub fn item_name(index: uint) -> &'static str {
// FIXME #4621: Method macros sure would be nice here.
pub
fn
freeze_trait
(
&
const
self
)
->
def_id
{
pub
fn
freeze_trait
(
&
self
)
->
def_id
{
self
.items
[
FreezeTraitLangItem
as
uint
]
.get
()
}
pub
fn
copy_trait
(
&
const
self
)
->
def_id
{
pub
fn
copy_trait
(
&
self
)
->
def_id
{
self
.items
[
CopyTraitLangItem
as
uint
]
.get
()
}
pub
fn
send_trait
(
&
const
self
)
->
def_id
{
pub
fn
send_trait
(
&
self
)
->
def_id
{
self
.items
[
SendTraitLangItem
as
uint
]
.get
()
}
pub
fn
sized_trait
(
&
const
self
)
->
def_id
{
pub
fn
sized_trait
(
&
self
)
->
def_id
{
self
.items
[
SizedTraitLangItem
as
uint
]
.get
()
}
pub
fn
drop_trait
(
&
const
self
)
->
def_id
{
pub
fn
drop_trait
(
&
self
)
->
def_id
{
self
.items
[
DropTraitLangItem
as
uint
]
.get
()
}
pub
fn
add_trait
(
&
const
self
)
->
def_id
{
pub
fn
add_trait
(
&
self
)
->
def_id
{
self
.items
[
AddTraitLangItem
as
uint
]
.get
()
}
pub
fn
sub_trait
(
&
const
self
)
->
def_id
{
pub
fn
sub_trait
(
&
self
)
->
def_id
{
self
.items
[
SubTraitLangItem
as
uint
]
.get
()
}
pub
fn
mul_trait
(
&
const
self
)
->
def_id
{
pub
fn
mul_trait
(
&
self
)
->
def_id
{
self
.items
[
MulTraitLangItem
as
uint
]
.get
()
}
pub
fn
div_trait
(
&
const
self
)
->
def_id
{
pub
fn
div_trait
(
&
self
)
->
def_id
{
self
.items
[
DivTraitLangItem
as
uint
]
.get
()
}
pub
fn
rem_trait
(
&
const
self
)
->
def_id
{
pub
fn
rem_trait
(
&
self
)
->
def_id
{
self
.items
[
RemTraitLangItem
as
uint
]
.get
()
}
pub
fn
neg_trait
(
&
const
self
)
->
def_id
{
pub
fn
neg_trait
(
&
self
)
->
def_id
{
self
.items
[
NegTraitLangItem
as
uint
]
.get
()
}
pub
fn
not_trait
(
&
const
self
)
->
def_id
{
pub
fn
not_trait
(
&
self
)
->
def_id
{
self
.items
[
NotTraitLangItem
as
uint
]
.get
()
}
pub
fn
bitxor_trait
(
&
const
self
)
->
def_id
{
pub
fn
bitxor_trait
(
&
self
)
->
def_id
{
self
.items
[
BitXorTraitLangItem
as
uint
]
.get
()
}
pub
fn
bitand_trait
(
&
const
self
)
->
def_id
{
pub
fn
bitand_trait
(
&
self
)
->
def_id
{
self
.items
[
BitAndTraitLangItem
as
uint
]
.get
()
}
pub
fn
bitor_trait
(
&
const
self
)
->
def_id
{
pub
fn
bitor_trait
(
&
self
)
->
def_id
{
self
.items
[
BitOrTraitLangItem
as
uint
]
.get
()
}
pub
fn
shl_trait
(
&
const
self
)
->
def_id
{
pub
fn
shl_trait
(
&
self
)
->
def_id
{
self
.items
[
ShlTraitLangItem
as
uint
]
.get
()
}
pub
fn
shr_trait
(
&
const
self
)
->
def_id
{
pub
fn
shr_trait
(
&
self
)
->
def_id
{
self
.items
[
ShrTraitLangItem
as
uint
]
.get
()
}
pub
fn
index_trait
(
&
const
self
)
->
def_id
{
pub
fn
index_trait
(
&
self
)
->
def_id
{
self
.items
[
IndexTraitLangItem
as
uint
]
.get
()
}
pub
fn
eq_trait
(
&
const
self
)
->
def_id
{
pub
fn
eq_trait
(
&
self
)
->
def_id
{
self
.items
[
EqTraitLangItem
as
uint
]
.get
()
}
pub
fn
ord_trait
(
&
const
self
)
->
def_id
{
pub
fn
ord_trait
(
&
self
)
->
def_id
{
self
.items
[
OrdTraitLangItem
as
uint
]
.get
()
}
pub
fn
str_eq_fn
(
&
const
self
)
->
def_id
{
pub
fn
str_eq_fn
(
&
self
)
->
def_id
{
self
.items
[
StrEqFnLangItem
as
uint
]
.get
()
}
pub
fn
uniq_str_eq_fn
(
&
const
self
)
->
def_id
{
pub
fn
uniq_str_eq_fn
(
&
self
)
->
def_id
{
self
.items
[
UniqStrEqFnLangItem
as
uint
]
.get
()
}
pub
fn
annihilate_fn
(
&
const
self
)
->
def_id
{
pub
fn
annihilate_fn
(
&
self
)
->
def_id
{
self
.items
[
AnnihilateFnLangItem
as
uint
]
.get
()
}
pub
fn
log_type_fn
(
&
const
self
)
->
def_id
{
pub
fn
log_type_fn
(
&
self
)
->
def_id
{
self
.items
[
LogTypeFnLangItem
as
uint
]
.get
()
}
pub
fn
fail_fn
(
&
const
self
)
->
def_id
{
pub
fn
fail_fn
(
&
self
)
->
def_id
{
self
.items
[
FailFnLangItem
as
uint
]
.get
()
}
pub
fn
fail_bounds_check_fn
(
&
const
self
)
->
def_id
{
pub
fn
fail_bounds_check_fn
(
&
self
)
->
def_id
{
self
.items
[
FailBoundsCheckFnLangItem
as
uint
]
.get
()
}
pub
fn
exchange_malloc_fn
(
&
const
self
)
->
def_id
{
pub
fn
exchange_malloc_fn
(
&
self
)
->
def_id
{
self
.items
[
ExchangeMallocFnLangItem
as
uint
]
.get
()
}
pub
fn
exchange_free_fn
(
&
const
self
)
->
def_id
{
pub
fn
exchange_free_fn
(
&
self
)
->
def_id
{
self
.items
[
ExchangeFreeFnLangItem
as
uint
]
.get
()
}
pub
fn
malloc_fn
(
&
const
self
)
->
def_id
{
pub
fn
malloc_fn
(
&
self
)
->
def_id
{
self
.items
[
MallocFnLangItem
as
uint
]
.get
()
}
pub
fn
free_fn
(
&
const
self
)
->
def_id
{
pub
fn
free_fn
(
&
self
)
->
def_id
{
self
.items
[
FreeFnLangItem
as
uint
]
.get
()
}
pub
fn
borrow_as_imm_fn
(
&
const
self
)
->
def_id
{
pub
fn
borrow_as_imm_fn
(
&
self
)
->
def_id
{
self
.items
[
BorrowAsImmFnLangItem
as
uint
]
.get
()
}
pub
fn
borrow_as_mut_fn
(
&
const
self
)
->
def_id
{
pub
fn
borrow_as_mut_fn
(
&
self
)
->
def_id
{
self
.items
[
BorrowAsMutFnLangItem
as
uint
]
.get
()
}
pub
fn
return_to_mut_fn
(
&
const
self
)
->
def_id
{
pub
fn
return_to_mut_fn
(
&
self
)
->
def_id
{
self
.items
[
ReturnToMutFnLangItem
as
uint
]
.get
()
}
pub
fn
check_not_borrowed_fn
(
&
const
self
)
->
def_id
{
pub
fn
check_not_borrowed_fn
(
&
self
)
->
def_id
{
self
.items
[
CheckNotBorrowedFnLangItem
as
uint
]
.get
()
}
pub
fn
strdup_uniq_fn
(
&
const
self
)
->
def_id
{
pub
fn
strdup_uniq_fn
(
&
self
)
->
def_id
{
self
.items
[
StrDupUniqFnLangItem
as
uint
]
.get
()
}
pub
fn
record_borrow_fn
(
&
const
self
)
->
def_id
{
pub
fn
record_borrow_fn
(
&
self
)
->
def_id
{
self
.items
[
RecordBorrowFnLangItem
as
uint
]
.get
()
}
pub
fn
unrecord_borrow_fn
(
&
const
self
)
->
def_id
{
pub
fn
unrecord_borrow_fn
(
&
self
)
->
def_id
{
self
.items
[
UnrecordBorrowFnLangItem
as
uint
]
.get
()
}
pub
fn
start_fn
(
&
const
self
)
->
def_id
{
pub
fn
start_fn
(
&
self
)
->
def_id
{
self
.items
[
StartFnLangItem
as
uint
]
.get
()
}
pub
fn
ty_desc
(
&
const
self
)
->
def_id
{
...
...
src/librustc/middle/ty.rs
浏览文件 @
b29c3686
...
...
@@ -3696,14 +3696,14 @@ pub enum DtorKind {
}
impl
DtorKind
{
pub
fn
is_not_present
(
&
const
self
)
->
bool
{
pub
fn
is_not_present
(
&
self
)
->
bool
{
match
*
self
{
NoDtor
=>
true
,
_
=>
false
}
}
pub
fn
is_present
(
&
const
self
)
->
bool
{
pub
fn
is_present
(
&
self
)
->
bool
{
!
self
.is_not_present
()
}
...
...
src/librustc/middle/typeck/check/vtable.rs
浏览文件 @
b29c3686
...
...
@@ -64,7 +64,7 @@ pub struct VtableContext {
}
impl
VtableContext
{
pub
fn
tcx
(
&
const
self
)
->
ty
::
ctxt
{
self
.ccx.tcx
}
pub
fn
tcx
(
&
self
)
->
ty
::
ctxt
{
self
.ccx.tcx
}
}
fn
has_trait_bounds
(
type_param_defs
:
&
[
ty
::
TypeParameterDef
])
->
bool
{
...
...
src/libstd/at_vec.rs
浏览文件 @
b29c3686
...
...
@@ -108,7 +108,7 @@ pub fn build_sized_opt<A>(size: Option<uint>,
/// Iterates over the `rhs` vector, copying each element and appending it to the
/// `lhs`. Afterwards, the `lhs` is then returned for use again.
#[inline]
pub
fn
append
<
T
:
Copy
>
(
lhs
:
@
[
T
],
rhs
:
&
const
[
T
])
->
@
[
T
]
{
pub
fn
append
<
T
:
Copy
>
(
lhs
:
@
[
T
],
rhs
:
&
[
T
])
->
@
[
T
]
{
do
build_sized
(
lhs
.len
()
+
rhs
.len
())
|
push
|
{
for
lhs
.iter
()
.advance
|
x
|
{
push
(
copy
*
x
);
}
for
uint
::
range
(
0
,
rhs
.len
())
|
i
|
{
push
(
copy
rhs
[
i
]);
}
...
...
@@ -180,9 +180,9 @@ pub mod traits {
use
kinds
::
Copy
;
use
ops
::
Add
;
impl
<
'self
,
T
:
Copy
>
Add
<&
'self
const
[
T
],
@
[
T
]
>
for
@
[
T
]
{
impl
<
'self
,
T
:
Copy
>
Add
<&
'self
[
T
],
@
[
T
]
>
for
@
[
T
]
{
#[inline]
fn
add
(
&
self
,
rhs
:
&
&
'self
const
[
T
])
->
@
[
T
]
{
fn
add
(
&
self
,
rhs
:
&
&
'self
[
T
])
->
@
[
T
]
{
append
(
*
self
,
(
*
rhs
))
}
}
...
...
src/libstd/hashmap.rs
浏览文件 @
b29c3686
...
...
@@ -282,10 +282,10 @@ fn search(&self, hash: uint,
impl
<
K
:
Hash
+
Eq
,
V
>
Container
for
HashMap
<
K
,
V
>
{
/// Return the number of elements in the map
fn
len
(
&
const
self
)
->
uint
{
self
.size
}
fn
len
(
&
self
)
->
uint
{
self
.size
}
/// Return true if the map contains no elements
fn
is_empty
(
&
const
self
)
->
bool
{
self
.len
()
==
0
}
fn
is_empty
(
&
self
)
->
bool
{
self
.len
()
==
0
}
}
impl
<
K
:
Hash
+
Eq
,
V
>
Mutable
for
HashMap
<
K
,
V
>
{
...
...
@@ -623,10 +623,10 @@ fn ne(&self, other: &HashSet<T>) -> bool { self.map != other.map }
impl
<
T
:
Hash
+
Eq
>
Container
for
HashSet
<
T
>
{
/// Return the number of elements in the set
fn
len
(
&
const
self
)
->
uint
{
self
.map
.len
()
}
fn
len
(
&
self
)
->
uint
{
self
.map
.len
()
}
/// Return true if the set contains no elements
fn
is_empty
(
&
const
self
)
->
bool
{
self
.map
.is_empty
()
}
fn
is_empty
(
&
self
)
->
bool
{
self
.map
.is_empty
()
}
}
impl
<
T
:
Hash
+
Eq
>
Mutable
for
HashSet
<
T
>
{
...
...
src/libstd/io.rs
浏览文件 @
b29c3686
...
...
@@ -1152,7 +1152,7 @@ fn get_type(&self) -> WriterType { File }
impl
Writer
for
*
libc
::
FILE
{
fn
write
(
&
self
,
v
:
&
[
u8
])
{
unsafe
{
do
vec
::
as_
const
_buf
(
v
)
|
vbuf
,
len
|
{
do
vec
::
as_
imm
_buf
(
v
)
|
vbuf
,
len
|
{
let
nout
=
libc
::
fwrite
(
vbuf
as
*
c_void
,
1
,
len
as
size_t
,
...
...
@@ -1203,9 +1203,9 @@ impl Writer for fd_t {
fn
write
(
&
self
,
v
:
&
[
u8
])
{
unsafe
{
let
mut
count
=
0u
;
do
vec
::
as_
const
_buf
(
v
)
|
vbuf
,
len
|
{
do
vec
::
as_
imm
_buf
(
v
)
|
vbuf
,
len
|
{
while
count
<
len
{
let
vb
=
ptr
::
const_
offset
(
vbuf
,
count
)
as
*
c_void
;
let
vb
=
ptr
::
offset
(
vbuf
,
count
)
as
*
c_void
;
let
nout
=
libc
::
write
(
*
self
,
vb
,
len
as
size_t
);
if
nout
<
0
as
ssize_t
{
error!
(
"error writing buffer"
);
...
...
src/libstd/option.rs
浏览文件 @
b29c3686
...
...
@@ -121,13 +121,13 @@ pub fn mut_iter<'r>(&'r mut self) -> OptionMutIterator<'r, T> {
/// Returns true if the option equals `none`
#[inline]
pub
fn
is_none
(
&
const
self
)
->
bool
{
pub
fn
is_none
(
&
self
)
->
bool
{
match
*
self
{
None
=>
true
,
Some
(
_
)
=>
false
}
}
/// Returns true if the option contains some value
#[inline]
pub
fn
is_some
(
&
const
self
)
->
bool
{
!
self
.is_none
()
}
pub
fn
is_some
(
&
self
)
->
bool
{
!
self
.is_none
()
}
/// Update an optional value by optionally running its content through a
/// function that returns an option.
...
...
src/libstd/ptr.rs
浏览文件 @
b29c3686
...
...
@@ -232,9 +232,9 @@ pub unsafe fn array_each<T>(arr: **T, cb: &fn(*T)) {
#[allow(missing_doc)]
pub
trait
RawPtr
<
T
>
{
fn
is_null
(
&
const
self
)
->
bool
;
fn
is_not_null
(
&
const
self
)
->
bool
;
unsafe
fn
to_option
(
&
const
self
)
->
Option
<&
T
>
;
fn
is_null
(
&
self
)
->
bool
;
fn
is_not_null
(
&
self
)
->
bool
;
unsafe
fn
to_option
(
&
self
)
->
Option
<&
T
>
;
fn
offset
(
&
self
,
count
:
uint
)
->
Self
;
}
...
...
@@ -242,11 +242,11 @@ pub trait RawPtr<T> {
impl
<
T
>
RawPtr
<
T
>
for
*
T
{
/// Returns true if the pointer is equal to the null pointer.
#[inline]
fn
is_null
(
&
const
self
)
->
bool
{
is_null
(
*
self
)
}
fn
is_null
(
&
self
)
->
bool
{
is_null
(
*
self
)
}
/// Returns true if the pointer is not equal to the null pointer.
#[inline]
fn
is_not_null
(
&
const
self
)
->
bool
{
is_not_null
(
*
self
)
}
fn
is_not_null
(
&
self
)
->
bool
{
is_not_null
(
*
self
)
}
///
/// Returns `None` if the pointer is null, or else returns the value wrapped
...
...
@@ -259,7 +259,7 @@ fn is_not_null(&const self) -> bool { is_not_null(*self) }
/// be pointing to invalid memory.
///
#[inline]
unsafe
fn
to_option
(
&
const
self
)
->
Option
<&
T
>
{
unsafe
fn
to_option
(
&
self
)
->
Option
<&
T
>
{
if
self
.is_null
()
{
None
}
else
{
Some
(
cast
::
transmute
(
*
self
))
}
...
...
@@ -274,11 +274,11 @@ fn offset(&self, count: uint) -> *T { offset(*self, count) }
impl
<
T
>
RawPtr
<
T
>
for
*
mut
T
{
/// Returns true if the pointer is equal to the null pointer.
#[inline]
fn
is_null
(
&
const
self
)
->
bool
{
is_null
(
*
self
)
}
fn
is_null
(
&
self
)
->
bool
{
is_null
(
*
self
)
}
/// Returns true if the pointer is not equal to the null pointer.
#[inline]
fn
is_not_null
(
&
const
self
)
->
bool
{
is_not_null
(
*
self
)
}
fn
is_not_null
(
&
self
)
->
bool
{
is_not_null
(
*
self
)
}
///
/// Returns `None` if the pointer is null, or else returns the value wrapped
...
...
@@ -291,7 +291,7 @@ fn is_not_null(&const self) -> bool { is_not_null(*self) }
/// be pointing to invalid memory.
///
#[inline]
unsafe
fn
to_option
(
&
const
self
)
->
Option
<&
T
>
{
unsafe
fn
to_option
(
&
self
)
->
Option
<&
T
>
{
if
self
.is_null
()
{
None
}
else
{
Some
(
cast
::
transmute
(
*
self
))
}
...
...
src/libstd/str.rs
浏览文件 @
b29c3686
...
...
@@ -569,7 +569,7 @@ fn match_at<'a,'b>(haystack: &'a str, needle: &'b str, at: uint) -> bool {
*/
/// Determines if a vector of bytes contains valid UTF-8
pub
fn
is_utf8
(
v
:
&
const
[
u8
])
->
bool
{
pub
fn
is_utf8
(
v
:
&
[
u8
])
->
bool
{
let
mut
i
=
0u
;
let
total
=
v
.len
();
while
i
<
total
{
...
...
@@ -815,7 +815,7 @@ pub unsafe fn from_buf(buf: *u8) -> ~str {
}
/// Create a Rust string from a *u8 buffer of the given length
pub
unsafe
fn
from_buf_len
(
buf
:
*
const
u8
,
len
:
uint
)
->
~
str
{
pub
unsafe
fn
from_buf_len
(
buf
:
*
u8
,
len
:
uint
)
->
~
str
{
let
mut
v
:
~
[
u8
]
=
vec
::
with_capacity
(
len
+
1
);
vec
::
as_mut_buf
(
v
,
|
vbuf
,
_
len
|
{
ptr
::
copy_memory
(
vbuf
,
buf
as
*
u8
,
len
)
...
...
@@ -838,8 +838,8 @@ pub unsafe fn from_c_str_len(c_str: *libc::c_char, len: uint) -> ~str {
}
/// Converts a vector of bytes to a new owned string.
pub
unsafe
fn
from_bytes
(
v
:
&
const
[
u8
])
->
~
str
{
do
vec
::
as_
const
_buf
(
v
)
|
buf
,
len
|
{
pub
unsafe
fn
from_bytes
(
v
:
&
[
u8
])
->
~
str
{
do
vec
::
as_
imm
_buf
(
v
)
|
buf
,
len
|
{
from_buf_len
(
buf
,
len
)
}
}
...
...
src/libstd/task/spawn.rs
浏览文件 @
b29c3686
...
...
@@ -129,7 +129,7 @@ struct TaskGroupData {
// A taskgroup is 'dead' when nothing can cause it to fail; only members can.
fn
taskgroup_is_dead
(
tg
:
&
TaskGroupData
)
->
bool
{
(
&
const
tg
.members
)
.is_empty
()
tg
.members
.is_empty
()
}
// A list-like structure by which taskgroups keep track of all ancestor groups
...
...
src/libstd/trie.rs
浏览文件 @
b29c3686
...
...
@@ -35,11 +35,11 @@ pub struct TrieMap<T> {
impl
<
T
>
Container
for
TrieMap
<
T
>
{
/// Return the number of elements in the map
#[inline]
fn
len
(
&
const
self
)
->
uint
{
self
.length
}
fn
len
(
&
self
)
->
uint
{
self
.length
}
/// Return true if the map contains no elements
#[inline]
fn
is_empty
(
&
const
self
)
->
bool
{
self
.len
()
==
0
}
fn
is_empty
(
&
self
)
->
bool
{
self
.len
()
==
0
}
}
impl
<
T
>
Mutable
for
TrieMap
<
T
>
{
...
...
@@ -179,11 +179,11 @@ pub struct TrieSet {
impl
Container
for
TrieSet
{
/// Return the number of elements in the set
#[inline]
fn
len
(
&
const
self
)
->
uint
{
self
.map
.len
()
}
fn
len
(
&
self
)
->
uint
{
self
.map
.len
()
}
/// Return true if the set contains no elements
#[inline]
fn
is_empty
(
&
const
self
)
->
bool
{
self
.map
.is_empty
()
}
fn
is_empty
(
&
self
)
->
bool
{
self
.map
.is_empty
()
}
}
impl
Mutable
for
TrieSet
{
...
...
src/libstd/vec.rs
浏览文件 @
b29c3686
...
...
@@ -64,7 +64,7 @@ unsafe fn vec_reserve_shared_actual(t: *TyDesc,
}
/// Returns true if two vectors have the same length
pub
fn
same_length
<
T
,
U
>
(
xs
:
&
const
[
T
],
ys
:
&
const
[
U
])
->
bool
{
pub
fn
same_length
<
T
,
U
>
(
xs
:
&
[
T
],
ys
:
&
[
U
])
->
bool
{
xs
.len
()
==
ys
.len
()
}
...
...
@@ -350,10 +350,7 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) {
if
v
.len
()
<
1
{
return
;
}
let
mut
last_written
=
0
;
let
mut
next_to_read
=
1
;
do
as_const_buf
(
*
v
)
|
p
,
ln
|
{
// We have a mutable reference to v, so we can make arbitrary
// changes. (cf. push and pop)
let
p
=
p
as
*
mut
T
;
do
as_mut_buf
(
*
v
)
|
p
,
ln
|
{
// last_written < next_to_read <= ln
while
next_to_read
<
ln
{
// last_written < next_to_read < ln
...
...
@@ -384,7 +381,7 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) {
/// Iterates over the `rhs` vector, copying each element and appending it to the
/// `lhs`. Afterwards, the `lhs` is then returned for use again.
#[inline]
pub
fn
append
<
T
:
Copy
>
(
lhs
:
~
[
T
],
rhs
:
&
const
[
T
])
->
~
[
T
]
{
pub
fn
append
<
T
:
Copy
>
(
lhs
:
~
[
T
],
rhs
:
&
[
T
])
->
~
[
T
]
{
let
mut
v
=
lhs
;
v
.push_all
(
rhs
);
v
...
...
@@ -831,7 +828,7 @@ pub fn unzip<T,U>(v: ~[(T, U)]) -> (~[T], ~[U]) {
/**
* Convert two vectors to a vector of pairs, by reference. As zip().
*/
pub
fn
zip_slice
<
T
:
Copy
,
U
:
Copy
>
(
v
:
&
const
[
T
],
u
:
&
const
[
U
])
pub
fn
zip_slice
<
T
:
Copy
,
U
:
Copy
>
(
v
:
&
[
T
],
u
:
&
[
U
])
->
~
[(
T
,
U
)]
{
let
mut
zipped
=
~
[];
let
sz
=
v
.len
();
...
...
@@ -893,7 +890,7 @@ pub fn reverse<T>(v: &mut [T]) {
}
/// Returns a vector with the order of elements reversed
pub
fn
reversed
<
T
:
Copy
>
(
v
:
&
const
[
T
])
->
~
[
T
]
{
pub
fn
reversed
<
T
:
Copy
>
(
v
:
&
[
T
])
->
~
[
T
]
{
let
mut
rs
:
~
[
T
]
=
~
[];
let
mut
i
=
v
.len
();
if
i
==
0
{
return
(
rs
);
}
else
{
i
-=
1
;
}
...
...
@@ -1003,16 +1000,6 @@ pub fn as_imm_buf<T,U>(s: &[T],
}
}
/// Similar to `as_imm_buf` but passing a `*const T`
#[inline]
pub
fn
as_const_buf
<
T
,
U
>
(
s
:
&
const
[
T
],
f
:
&
fn
(
*
const
T
,
uint
)
->
U
)
->
U
{
unsafe
{
let
v
:
*
(
*
const
T
,
uint
)
=
transmute
(
&
s
);
let
(
buf
,
len
)
=
*
v
;
f
(
buf
,
len
/
sys
::
nonzero_size_of
::
<
T
>
())
}
}
/// Similar to `as_imm_buf` but passing a `*mut T`
#[inline]
pub
fn
as_mut_buf
<
T
,
U
>
(
s
:
&
mut
[
T
],
f
:
&
fn
(
*
mut
T
,
uint
)
->
U
)
->
U
{
...
...
@@ -1198,25 +1185,25 @@ pub mod traits {
use
ops
::
Add
;
use
vec
::
append
;
impl
<
'self
,
T
:
Copy
>
Add
<&
'self
const
[
T
],
~
[
T
]
>
for
~
[
T
]
{
impl
<
'self
,
T
:
Copy
>
Add
<&
'self
[
T
],
~
[
T
]
>
for
~
[
T
]
{
#[inline]
fn
add
(
&
self
,
rhs
:
&
&
'self
const
[
T
])
->
~
[
T
]
{
fn
add
(
&
self
,
rhs
:
&
&
'self
[
T
])
->
~
[
T
]
{
append
(
copy
*
self
,
(
*
rhs
))
}
}
}
impl
<
'self
,
T
>
Container
for
&
'self
const
[
T
]
{
impl
<
'self
,
T
>
Container
for
&
'self
[
T
]
{
/// Returns true if a vector contains no elements
#[inline]
fn
is_empty
(
&
self
)
->
bool
{
as_
const
_buf
(
*
self
,
|
_
p
,
len
|
len
==
0u
)
as_
imm
_buf
(
*
self
,
|
_
p
,
len
|
len
==
0u
)
}
/// Returns the length of a vector
#[inline]
fn
len
(
&
self
)
->
uint
{
as_
const
_buf
(
*
self
,
|
_
p
,
len
|
len
)
as_
imm
_buf
(
*
self
,
|
_
p
,
len
|
len
)
}
}
...
...
@@ -1224,13 +1211,13 @@ impl<T> Container for ~[T] {
/// Returns true if a vector contains no elements
#[inline]
fn
is_empty
(
&
self
)
->
bool
{
as_
const
_buf
(
*
self
,
|
_
p
,
len
|
len
==
0u
)
as_
imm
_buf
(
*
self
,
|
_
p
,
len
|
len
==
0u
)
}
/// Returns the length of a vector
#[inline]
fn
len
(
&
self
)
->
uint
{
as_
const
_buf
(
*
self
,
|
_
p
,
len
|
len
)
as_
imm
_buf
(
*
self
,
|
_
p
,
len
|
len
)
}
}
...
...
@@ -1843,7 +1830,7 @@ fn clear(&mut self) { self.truncate(0) }
#[allow(missing_doc)]
pub
trait
OwnedCopyableVector
<
T
:
Copy
>
{
fn
push_all
(
&
mut
self
,
rhs
:
&
const
[
T
]);
fn
push_all
(
&
mut
self
,
rhs
:
&
[
T
]);
fn
grow
(
&
mut
self
,
n
:
uint
,
initval
:
&
T
);
fn
grow_set
(
&
mut
self
,
index
:
uint
,
initval
:
&
T
,
val
:
T
);
}
...
...
@@ -1860,7 +1847,7 @@ impl<T:Copy> OwnedCopyableVector<T> for ~[T] {
/// assert!(a == ~[1, 2, 3, 4]);
/// ~~~
#[inline]
fn
push_all
(
&
mut
self
,
rhs
:
&
const
[
T
])
{
fn
push_all
(
&
mut
self
,
rhs
:
&
[
T
])
{
let
new_len
=
self
.len
()
+
rhs
.len
();
self
.reserve
(
new_len
);
...
...
@@ -2017,7 +2004,7 @@ pub mod raw {
use
ptr
;
use
sys
;
use
unstable
::
intrinsics
;
use
vec
::{
UnboxedVecRepr
,
as_
const
_buf
,
as_mut_buf
,
with_capacity
};
use
vec
::{
UnboxedVecRepr
,
as_
imm
_buf
,
as_mut_buf
,
with_capacity
};
use
util
;
/// The internal representation of a (boxed) vector
...
...
@@ -2065,15 +2052,6 @@ pub fn to_ptr<T>(v: &[T]) -> *T {
}
}
/** see `to_ptr()` */
#[inline]
pub
fn
to_const_ptr
<
T
>
(
v
:
&
const
[
T
])
->
*
const
T
{
unsafe
{
let
repr
:
**
SliceRepr
=
transmute
(
&
v
);
transmute
(
&
((
**
repr
)
.data
))
}
}
/** see `to_ptr()` */
#[inline]
pub
fn
to_mut_ptr
<
T
>
(
v
:
&
mut
[
T
])
->
*
mut
T
{
...
...
@@ -2113,8 +2091,8 @@ pub unsafe fn mut_buf_as_slice<T,U>(p: *mut T,
* Unchecked vector indexing.
*/
#[inline]
pub
unsafe
fn
get
<
T
:
Copy
>
(
v
:
&
const
[
T
],
i
:
uint
)
->
T
{
as_
const_buf
(
v
,
|
p
,
_
len
|
copy
*
ptr
::
const_
offset
(
p
,
i
))
pub
unsafe
fn
get
<
T
:
Copy
>
(
v
:
&
[
T
],
i
:
uint
)
->
T
{
as_
imm_buf
(
v
,
|
p
,
_
len
|
copy
*
ptr
::
offset
(
p
,
i
))
}
/**
...
...
@@ -2156,13 +2134,13 @@ pub unsafe fn from_buf_raw<T>(ptr: *T, elts: uint) -> ~[T] {
* may overlap.
*/
#[inline]
pub
unsafe
fn
copy_memory
<
T
>
(
dst
:
&
mut
[
T
],
src
:
&
const
[
T
],
pub
unsafe
fn
copy_memory
<
T
>
(
dst
:
&
mut
[
T
],
src
:
&
[
T
],
count
:
uint
)
{
assert
!
(
dst
.len
()
>=
count
);
assert
!
(
src
.len
()
>=
count
);
do
as_mut_buf
(
dst
)
|
p_dst
,
_
len_dst
|
{
do
as_
const
_buf
(
src
)
|
p_src
,
_
len_src
|
{
do
as_
imm
_buf
(
src
)
|
p_src
,
_
len_src
|
{
ptr
::
copy_memory
(
p_dst
,
p_src
,
count
)
}
}
...
...
@@ -2238,7 +2216,7 @@ pub fn gt(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) > 0 }
* may overlap.
*/
#[inline]
pub
fn
copy_memory
(
dst
:
&
mut
[
u8
],
src
:
&
const
[
u8
],
count
:
uint
)
{
pub
fn
copy_memory
(
dst
:
&
mut
[
u8
],
src
:
&
[
u8
],
count
:
uint
)
{
// Bound checks are done at vec::raw::copy_memory.
unsafe
{
vec
::
raw
::
copy_memory
(
dst
,
src
,
count
)
}
}
...
...
@@ -3690,16 +3668,6 @@ fn test_as_imm_buf_fail() {
}
}
#[test]
#[ignore(windows)]
#[should_fail]
fn
test_as_const_buf_fail
()
{
let
v
=
[(
~
0
,
@
0
),
(
~
0
,
@
0
),
(
~
0
,
@
0
),
(
~
0
,
@
0
)];
do
as_const_buf
(
v
)
|
_
buf
,
_
i
|
{
fail
!
()
}
}
#[test]
#[ignore(cfg(windows))]
#[should_fail]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录