Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
96cd61ad
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,发现更多精彩内容 >>
提交
96cd61ad
编写于
6月 11, 2013
作者:
H
Huon Wilson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
std: convert {vec,str}::to_owned to methods.
上级
e06579bc
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
95 addition
and
99 deletion
+95
-99
src/libextra/flatpipes.rs
src/libextra/flatpipes.rs
+1
-1
src/libextra/getopts.rs
src/libextra/getopts.rs
+22
-22
src/libextra/md4.rs
src/libextra/md4.rs
+1
-1
src/libextra/num/bigint.rs
src/libextra/num/bigint.rs
+1
-1
src/libextra/stats.rs
src/libextra/stats.rs
+1
-1
src/libextra/time.rs
src/libextra/time.rs
+1
-1
src/libfuzzer/fuzzer.rc
src/libfuzzer/fuzzer.rc
+1
-1
src/librustc/driver/driver.rs
src/librustc/driver/driver.rs
+2
-2
src/librustc/metadata/decoder.rs
src/librustc/metadata/decoder.rs
+1
-1
src/librustc/metadata/encoder.rs
src/librustc/metadata/encoder.rs
+1
-1
src/librustc/metadata/filesearch.rs
src/librustc/metadata/filesearch.rs
+2
-2
src/librustc/metadata/loader.rs
src/librustc/metadata/loader.rs
+1
-1
src/librustc/middle/check_match.rs
src/librustc/middle/check_match.rs
+11
-11
src/librustc/middle/trans/adt.rs
src/librustc/middle/trans/adt.rs
+1
-1
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/base.rs
+1
-1
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+1
-1
src/librustdoc/desc_to_brief_pass.rs
src/librustdoc/desc_to_brief_pass.rs
+3
-3
src/libstd/io.rs
src/libstd/io.rs
+1
-1
src/libstd/path.rs
src/libstd/path.rs
+6
-6
src/libstd/rand.rs
src/libstd/rand.rs
+1
-1
src/libstd/str.rs
src/libstd/str.rs
+19
-15
src/libstd/vec.rs
src/libstd/vec.rs
+5
-11
src/libsyntax/attr.rs
src/libsyntax/attr.rs
+1
-1
src/libsyntax/ext/asm.rs
src/libsyntax/ext/asm.rs
+1
-1
src/libsyntax/ext/base.rs
src/libsyntax/ext/base.rs
+1
-1
src/libsyntax/ext/log_syntax.rs
src/libsyntax/ext/log_syntax.rs
+1
-1
src/libsyntax/ext/quote.rs
src/libsyntax/ext/quote.rs
+2
-4
src/libsyntax/ext/trace_macros.rs
src/libsyntax/ext/trace_macros.rs
+1
-1
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/ext/tt/macro_rules.rs
+2
-2
src/test/run-pass/struct-order-of-eval-1.rs
src/test/run-pass/struct-order-of-eval-1.rs
+1
-1
src/test/run-pass/struct-order-of-eval-2.rs
src/test/run-pass/struct-order-of-eval-2.rs
+1
-1
未找到文件。
src/libextra/flatpipes.rs
浏览文件 @
96cd61ad
...
...
@@ -450,7 +450,7 @@ pub fn deserialize_buffer<D: Decoder + FromReader,
T
:
Decodable
<
D
>>
(
buf
:
&
[
u8
])
->
T
{
let
buf
=
vec
::
to_owned
(
buf
);
let
buf
=
buf
.to_owned
(
);
let
buf_reader
=
@
BufReader
::
new
(
buf
);
let
reader
=
buf_reader
as
@
Reader
;
let
mut
deser
:
D
=
FromReader
::
from_reader
(
reader
);
...
...
src/libextra/getopts.rs
浏览文件 @
96cd61ad
...
...
@@ -345,7 +345,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
}
i
+=
1
;
}
return
Ok
(
Matches
{
opts
:
vec
::
to_owned
(
opts
),
return
Ok
(
Matches
{
opts
:
opts
.to_owned
(
),
vals
:
vals
,
free
:
free
});
}
...
...
@@ -447,7 +447,7 @@ pub fn opt_default(mm: &Matches, nm: &str, def: &str) -> Option<~str> {
let
vals
=
opt_vals
(
mm
,
nm
);
if
vals
.is_empty
()
{
return
None
::
<~
str
>
;
}
return
match
vals
[
0
]
{
Val
(
ref
s
)
=>
Some
::
<~
str
>
(
copy
*
s
),
_
=>
Some
::
<~
str
>
(
str
::
to_owned
(
def
))
}
_
=>
Some
::
<~
str
>
(
def
.to_owned
(
))
}
}
#[deriving(Eq)]
...
...
@@ -487,10 +487,10 @@ pub fn reqopt(short_name: &str, long_name: &str,
desc
:
&
str
,
hint
:
&
str
)
->
OptGroup
{
let
len
=
short_name
.len
();
assert
!
(
len
==
1
||
len
==
0
);
return
OptGroup
{
short_name
:
s
tr
::
to_owned
(
short_name
),
long_name
:
str
::
to_owned
(
long_name
),
hint
:
str
::
to_owned
(
hint
),
desc
:
str
::
to_owned
(
desc
),
return
OptGroup
{
short_name
:
s
hort_name
.to_owned
(
),
long_name
:
long_name
.to_owned
(
),
hint
:
hint
.to_owned
(
),
desc
:
desc
.to_owned
(
),
hasarg
:
Yes
,
occur
:
Req
};
}
...
...
@@ -500,10 +500,10 @@ pub fn optopt(short_name: &str, long_name: &str,
desc
:
&
str
,
hint
:
&
str
)
->
OptGroup
{
let
len
=
short_name
.len
();
assert
!
(
len
==
1
||
len
==
0
);
return
OptGroup
{
short_name
:
s
tr
::
to_owned
(
short_name
),
long_name
:
str
::
to_owned
(
long_name
),
hint
:
str
::
to_owned
(
hint
),
desc
:
str
::
to_owned
(
desc
),
return
OptGroup
{
short_name
:
s
hort_name
.to_owned
(
),
long_name
:
long_name
.to_owned
(
),
hint
:
hint
.to_owned
(
),
desc
:
desc
.to_owned
(
),
hasarg
:
Yes
,
occur
:
Optional
};
}
...
...
@@ -513,10 +513,10 @@ pub fn optflag(short_name: &str, long_name: &str,
desc
:
&
str
)
->
OptGroup
{
let
len
=
short_name
.len
();
assert
!
(
len
==
1
||
len
==
0
);
return
OptGroup
{
short_name
:
s
tr
::
to_owned
(
short_name
),
long_name
:
str
::
to_owned
(
long_name
),
return
OptGroup
{
short_name
:
s
hort_name
.to_owned
(
),
long_name
:
long_name
.to_owned
(
),
hint
:
~
""
,
desc
:
str
::
to_owned
(
desc
),
desc
:
desc
.to_owned
(
),
hasarg
:
No
,
occur
:
Optional
};
}
...
...
@@ -526,10 +526,10 @@ pub fn optflagopt(short_name: &str, long_name: &str,
desc
:
&
str
,
hint
:
&
str
)
->
OptGroup
{
let
len
=
short_name
.len
();
assert
!
(
len
==
1
||
len
==
0
);
return
OptGroup
{
short_name
:
s
tr
::
to_owned
(
short_name
),
long_name
:
str
::
to_owned
(
long_name
),
hint
:
str
::
to_owned
(
hint
),
desc
:
str
::
to_owned
(
desc
),
return
OptGroup
{
short_name
:
s
hort_name
.to_owned
(
),
long_name
:
long_name
.to_owned
(
),
hint
:
hint
.to_owned
(
),
desc
:
desc
.to_owned
(
),
hasarg
:
Maybe
,
occur
:
Optional
};
}
...
...
@@ -542,10 +542,10 @@ pub fn optmulti(short_name: &str, long_name: &str,
desc
:
&
str
,
hint
:
&
str
)
->
OptGroup
{
let
len
=
short_name
.len
();
assert
!
(
len
==
1
||
len
==
0
);
return
OptGroup
{
short_name
:
s
tr
::
to_owned
(
short_name
),
long_name
:
str
::
to_owned
(
long_name
),
hint
:
str
::
to_owned
(
hint
),
desc
:
str
::
to_owned
(
desc
),
return
OptGroup
{
short_name
:
s
hort_name
.to_owned
(
),
long_name
:
long_name
.to_owned
(
),
hint
:
hint
.to_owned
(
),
desc
:
desc
.to_owned
(
),
hasarg
:
Yes
,
occur
:
Multi
};
}
...
...
@@ -654,7 +654,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> ~str {
row
});
return
str
::
to_owned
(
brief
)
+
return
brief
.to_owned
(
)
+
"
\n\n
Options:
\n
"
+
rows
.connect
(
"
\n
"
)
+
"
\n\n
"
;
...
...
src/libextra/md4.rs
浏览文件 @
96cd61ad
...
...
@@ -30,7 +30,7 @@ pub fn md4(msg: &[u8]) -> Quad {
let
orig_len
:
u64
=
(
msg
.len
()
*
8u
)
as
u64
;
// pad message
let
mut
msg
=
vec
::
append
(
vec
::
to_owned
(
msg
),
[
0x80u8
]);
let
mut
msg
=
vec
::
append
(
msg
.to_owned
(
),
[
0x80u8
]);
let
mut
bitlen
=
orig_len
+
8u64
;
while
(
bitlen
+
64u64
)
%
512u64
>
0u64
{
msg
.push
(
0u8
);
...
...
src/libextra/num/bigint.rs
浏览文件 @
96cd61ad
...
...
@@ -564,7 +564,7 @@ pub fn from_uint(n: uint) -> BigUint {
/// Creates and initializes an BigUint.
pub
fn
from_slice
(
slice
:
&
[
BigDigit
])
->
BigUint
{
return
BigUint
::
new
(
vec
::
to_owned
(
slice
));
return
BigUint
::
new
(
slice
.to_owned
(
));
}
/// Creates and initializes an BigUint.
...
...
src/libextra/stats.rs
浏览文件 @
96cd61ad
...
...
@@ -57,7 +57,7 @@ fn mean(self) -> f64 {
fn
median
(
self
)
->
f64
{
assert
!
(
self
.len
()
!=
0
);
let
mut
tmp
=
vec
::
to_owned
(
self
);
let
mut
tmp
=
self
.to_owned
(
);
sort
::
tim_sort
(
tmp
);
if
tmp
.len
()
&
1
==
0
{
let
m
=
tmp
.len
()
/
2
;
...
...
src/libextra/time.rs
浏览文件 @
96cd61ad
...
...
@@ -1029,7 +1029,7 @@ fn test_strptime() {
fn
test
(
s
:
&
str
,
format
:
&
str
)
->
bool
{
match
strptime
(
s
,
format
)
{
Ok
(
ref
tm
)
=>
tm
.strftime
(
format
)
==
s
tr
::
to_owned
(
s
),
Ok
(
ref
tm
)
=>
tm
.strftime
(
format
)
==
s
.to_owned
(
),
Err
(
e
)
=>
fail
!
(
e
)
}
}
...
...
src/libfuzzer/fuzzer.rc
浏览文件 @
96cd61ad
...
...
@@ -328,7 +328,7 @@ pub fn check_variants_T<T:Copy>(crate: @ast::crate,
if L < 100 {
do under(uint::min(L, 20)) |i| {
error!("Replacing... #%?", uint::to_str(i));
let fname =
str::to_owned(filename.to_str()
);
let fname =
filename.to_str(
);
do under(uint::min(L, 30)) |j| {
let fname = fname.to_str();
error!("With... %?", stringifier(things[j], intr));
...
...
src/librustc/driver/driver.rs
浏览文件 @
96cd61ad
...
...
@@ -96,9 +96,9 @@ pub fn default_configuration(sess: Session, argv0: @~str, input: &input) ->
};
return
~
[
// Target bindings.
attr
::
mk_word_item
(
@
str
::
to_owned
(
os
::
FAMILY
)),
attr
::
mk_word_item
(
@
os
::
FAMILY
.to_owned
(
)),
mk
(
@~
"target_os"
,
@
tos
),
mk
(
@~
"target_family"
,
@
str
::
to_owned
(
os
::
FAMILY
)),
mk
(
@~
"target_family"
,
@
os
::
FAMILY
.to_owned
(
)),
mk
(
@~
"target_arch"
,
@
arch
),
mk
(
@~
"target_endian"
,
@
end
),
mk
(
@~
"target_word_size"
,
@
wordsz
),
...
...
src/librustc/metadata/decoder.rs
浏览文件 @
96cd61ad
...
...
@@ -570,7 +570,7 @@ pub fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt,
let
item_doc
=
lookup_item
(
id
,
cdata
.data
);
let
path
=
{
let
item_path
=
item_path
(
item_doc
);
vec
::
to_owned
(
item_path
.init
()
)
item_path
.init
()
.to_owned
(
)
};
match
decode_inlined_item
(
cdata
,
tcx
,
copy
path
,
item_doc
)
{
Some
(
ref
ii
)
=>
csearch
::
found
((
/*bad*/
copy
*
ii
)),
...
...
src/librustc/metadata/encoder.rs
浏览文件 @
96cd61ad
...
...
@@ -1516,7 +1516,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
let
writer_bytes
:
&
mut
~
[
u8
]
=
wr
.bytes
;
vec
::
to_owned
(
metadata_encoding_version
)
+
metadata_encoding_version
.to_owned
(
)
+
flate
::
deflate_bytes
(
*
writer_bytes
)
}
...
...
src/librustc/metadata/filesearch.rs
浏览文件 @
96cd61ad
...
...
@@ -81,7 +81,7 @@ fn get_target_lib_file_path(&self, file: &Path) -> Path {
@
FileSearchImpl
{
sysroot
:
sysroot
,
addl_lib_search_paths
:
addl_lib_search_paths
,
target_triple
:
str
::
to_owned
(
target_triple
)
target_triple
:
target_triple
.to_owned
(
)
}
as
@
FileSearch
}
...
...
@@ -107,7 +107,7 @@ pub fn search<T:Copy>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
pub
fn
relative_target_lib_path
(
target_triple
:
&
str
)
->
Path
{
Path
(
libdir
())
.push_many
([
~
"rustc"
,
str
::
to_owned
(
target_triple
),
target_triple
.to_owned
(
),
libdir
()])
}
...
...
src/librustc/metadata/loader.rs
浏览文件 @
96cd61ad
...
...
@@ -80,7 +80,7 @@ fn libname(cx: &Context) -> (~str, ~str) {
os_freebsd
=>
(
freebsd
::
DLL_PREFIX
,
freebsd
::
DLL_SUFFIX
),
};
(
str
::
to_owned
(
dll_prefix
),
str
::
to_owned
(
dll_suffix
))
(
dll_prefix
.to_owned
(),
dll_suffix
.to_owned
(
))
}
fn
find_library_crate_aux
(
...
...
src/librustc/middle/check_match.rs
浏览文件 @
96cd61ad
...
...
@@ -495,7 +495,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
match
cx
.tcx.def_map
.find
(
&
pat_id
)
{
Some
(
&
def_variant
(
_
,
id
))
=>
{
if
variant
(
id
)
==
*
ctor_id
{
Some
(
vec
::
to_owned
(
r
.tail
()
))
Some
(
r
.tail
()
.to_owned
(
))
}
else
{
None
}
...
...
@@ -533,7 +533,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
_
=>
fail
!
(
"type error"
)
};
if
match_
{
Some
(
vec
::
to_owned
(
r
.tail
()
))
Some
(
r
.tail
()
.to_owned
(
))
}
else
{
None
}
...
...
@@ -580,7 +580,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
_
=>
fail
!
(
"type error"
)
};
if
match_
{
Some
(
vec
::
to_owned
(
r
.tail
()
))
Some
(
r
.tail
()
.to_owned
(
))
}
else
{
None
}
...
...
@@ -590,7 +590,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
Some
(
args
)
=>
args
,
None
=>
vec
::
from_elem
(
arity
,
wild
())
};
Some
(
vec
::
append
(
args
,
vec
::
to_owned
(
r
.tail
()
)))
Some
(
vec
::
append
(
args
,
r
.tail
()
.to_owned
(
)))
}
def_variant
(
_
,
_
)
=>
None
,
...
...
@@ -602,7 +602,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
Some
(
args
)
=>
new_args
=
args
,
None
=>
new_args
=
vec
::
from_elem
(
arity
,
wild
())
}
Some
(
vec
::
append
(
new_args
,
vec
::
to_owned
(
r
.tail
()
)))
Some
(
vec
::
append
(
new_args
,
r
.tail
()
.to_owned
(
)))
}
_
=>
None
}
...
...
@@ -620,7 +620,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
_
=>
wild
()
}
});
Some
(
vec
::
append
(
args
,
vec
::
to_owned
(
r
.tail
()
)))
Some
(
vec
::
append
(
args
,
r
.tail
()
.to_owned
(
)))
}
else
{
None
}
...
...
@@ -651,7 +651,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
_
=>
wild
()
}
});
Some
(
vec
::
append
(
args
,
vec
::
to_owned
(
r
.tail
()
)))
Some
(
vec
::
append
(
args
,
r
.tail
()
.to_owned
(
)))
}
}
}
...
...
@@ -687,14 +687,14 @@ pub fn specialize(cx: @MatchCheckCtxt,
single
=>
true
,
_
=>
fail
!
(
"type error"
)
};
if
match_
{
Some
(
vec
::
to_owned
(
r
.tail
()
))
}
else
{
None
}
if
match_
{
Some
(
r
.tail
()
.to_owned
(
))
}
else
{
None
}
}
pat_range
(
lo
,
hi
)
=>
{
let
(
c_lo
,
c_hi
)
=
match
*
ctor_id
{
val
(
ref
v
)
=>
((
/*bad*/
copy
*
v
),
(
/*bad*/
copy
*
v
)),
range
(
ref
lo
,
ref
hi
)
=>
((
/*bad*/
copy
*
lo
),
(
/*bad*/
copy
*
hi
)),
single
=>
return
Some
(
vec
::
to_owned
(
r
.tail
()
)),
single
=>
return
Some
(
r
.tail
()
.to_owned
(
)),
_
=>
fail
!
(
"type error"
)
};
let
v_lo
=
eval_const_expr
(
cx
.tcx
,
lo
);
...
...
@@ -704,7 +704,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
let
m2
=
compare_const_vals
(
&
c_hi
,
&
v_hi
);
match
(
m1
,
m2
)
{
(
Some
(
val1
),
Some
(
val2
))
if
val1
>=
0
&&
val2
<=
0
=>
{
Some
(
vec
::
to_owned
(
r
.tail
()
))
Some
(
r
.tail
()
.to_owned
(
))
},
(
Some
(
_
),
Some
(
_
))
=>
None
,
_
=>
{
...
...
@@ -745,7 +745,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
}
pub
fn
default
(
cx
:
@
MatchCheckCtxt
,
r
:
&
[
@
pat
])
->
Option
<~
[
@
pat
]
>
{
if
is_wild
(
cx
,
r
[
0
])
{
Some
(
vec
::
to_owned
(
r
.tail
()
))
}
if
is_wild
(
cx
,
r
[
0
])
{
Some
(
r
.tail
()
.to_owned
(
))
}
else
{
None
}
}
...
...
src/librustc/middle/trans/adt.rs
浏览文件 @
96cd61ad
...
...
@@ -218,7 +218,7 @@ fn mk_struct(cx: @CrateContext, tys: &[ty::t], packed: bool) -> Struct {
size
:
machine
::
llsize_of_alloc
(
cx
,
llty_rec
)
/*bad*/
as
u64
,
align
:
machine
::
llalign_of_min
(
cx
,
llty_rec
)
/*bad*/
as
u64
,
packed
:
packed
,
fields
:
vec
::
to_owned
(
tys
)
fields
:
tys
.to_owned
(
)
}
}
...
...
src/librustc/middle/trans/base.rs
浏览文件 @
96cd61ad
...
...
@@ -114,7 +114,7 @@ impl get_insn_ctxt for @CrateContext {
fn
insn_ctxt
(
&
self
,
s
:
&
str
)
->
icx_popper
{
debug!
(
"new insn_ctxt: %s"
,
s
);
if
self
.sess
.count_llvm_insns
()
{
self
.stats.llvm_insn_ctxt
.push
(
s
tr
::
to_owned
(
s
));
self
.stats.llvm_insn_ctxt
.push
(
s
.to_owned
(
));
}
icx_popper
(
*
self
)
}
...
...
src/librustc/middle/ty.rs
浏览文件 @
96cd61ad
...
...
@@ -3898,7 +3898,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
}
ast_map
::
node_variant
(
ref
variant
,
_
,
path
)
=>
{
vec
::
append_one
(
vec
::
to_owned
(
vec
::
init
(
*
path
)
),
vec
::
append_one
(
path
.init
()
.to_owned
(
),
ast_map
::
path_name
((
*
variant
)
.node.name
))
}
...
...
src/librustdoc/desc_to_brief_pass.rs
浏览文件 @
96cd61ad
...
...
@@ -131,13 +131,13 @@ fn first_sentence_(s: &str) -> ~str {
});
match
idx
{
Some
(
idx
)
if
idx
>
2u
=>
{
s
tr
::
to_owned
(
s
.slice
(
0
,
idx
-
1
)
)
s
.slice_to
(
idx
-
1
)
.to_owned
(
)
}
_
=>
{
if
s
.ends_with
(
"."
)
{
s
tr
::
to_owned
(
s
)
s
.to_owned
(
)
}
else
{
s
tr
::
to_owned
(
s
)
s
.to_owned
(
)
}
}
}
...
...
src/libstd/io.rs
浏览文件 @
96cd61ad
...
...
@@ -761,7 +761,7 @@ fn each_line(&self, it: &fn(s: &str) -> bool) -> bool {
fn
read_lines
(
&
self
)
->
~
[
~
str
]
{
do
vec
::
build
|
push
|
{
for
self
.each_line
|
line
|
{
push
(
str
::
to_owned
(
line
));
push
(
line
.to_owned
(
));
}
}
}
...
...
src/libstd/path.rs
浏览文件 @
96cd61ad
...
...
@@ -515,7 +515,7 @@ fn with_filename(&self, f: &str) -> PosixPath {
fn
with_filestem
(
&
self
,
s
:
&
str
)
->
PosixPath
{
match
self
.filetype
()
{
None
=>
self
.with_filename
(
s
),
Some
(
ref
t
)
=>
self
.with_filename
(
s
tr
::
to_owned
(
s
)
+
*
t
),
Some
(
ref
t
)
=>
self
.with_filename
(
s
.to_owned
(
)
+
*
t
),
}
}
...
...
@@ -657,7 +657,7 @@ fn from_str(s: &str) -> WindowsPath {
(
None
,
None
)
=>
{
host
=
None
;
device
=
None
;
rest
=
s
tr
::
to_owned
(
s
);
rest
=
s
.to_owned
(
);
}
}
...
...
@@ -729,7 +729,7 @@ fn with_filename(&self, f: &str) -> WindowsPath {
fn
with_filestem
(
&
self
,
s
:
&
str
)
->
WindowsPath
{
match
self
.filetype
()
{
None
=>
self
.with_filename
(
s
),
Some
(
ref
t
)
=>
self
.with_filename
(
s
tr
::
to_owned
(
s
)
+
*
t
),
Some
(
ref
t
)
=>
self
.with_filename
(
s
.to_owned
(
)
+
*
t
),
}
}
...
...
@@ -984,7 +984,7 @@ fn test_filetype_foo() {
fn
test_posix_paths
()
{
fn
t
(
wp
:
&
PosixPath
,
s
:
&
str
)
{
let
ss
=
wp
.to_str
();
let
sss
=
s
tr
::
to_owned
(
s
);
let
sss
=
s
.to_owned
(
);
if
(
ss
!=
sss
)
{
debug!
(
"got %s"
,
ss
);
debug!
(
"expected %s"
,
sss
);
...
...
@@ -1042,7 +1042,7 @@ fn t(wp: &PosixPath, s: &str) {
fn
test_normalize
()
{
fn
t
(
wp
:
&
PosixPath
,
s
:
&
str
)
{
let
ss
=
wp
.to_str
();
let
sss
=
s
tr
::
to_owned
(
s
);
let
sss
=
s
.to_owned
(
);
if
(
ss
!=
sss
)
{
debug!
(
"got %s"
,
ss
);
debug!
(
"expected %s"
,
sss
);
...
...
@@ -1105,7 +1105,7 @@ fn test_extract_drive_prefixes() {
fn
test_windows_paths
()
{
fn
t
(
wp
:
&
WindowsPath
,
s
:
&
str
)
{
let
ss
=
wp
.to_str
();
let
sss
=
s
tr
::
to_owned
(
s
);
let
sss
=
s
.to_owned
(
);
if
(
ss
!=
sss
)
{
debug!
(
"got %s"
,
ss
);
debug!
(
"expected %s"
,
sss
);
...
...
src/libstd/rand.rs
浏览文件 @
96cd61ad
...
...
@@ -577,7 +577,7 @@ fn weighted_vec<T:Copy>(&mut self, v: &[Weighted<T>]) -> ~[T] {
/// Shuffle a vec
fn
shuffle
<
T
:
Copy
>
(
&
mut
self
,
values
:
&
[
T
])
->
~
[
T
]
{
let
mut
m
=
v
ec
::
to_owned
(
values
);
let
mut
m
=
v
alues
.to_owned
(
);
self
.shuffle_mut
(
m
);
m
}
...
...
src/libstd/str.rs
浏览文件 @
96cd61ad
...
...
@@ -107,23 +107,17 @@ pub fn from_bytes_slice<'a>(vector: &'a [u8]) -> &'a str {
}
}
/// Copy a slice into a new unique str
#[inline(always)]
pub
fn
to_owned
(
s
:
&
str
)
->
~
str
{
unsafe
{
raw
::
slice_bytes_owned
(
s
,
0
,
s
.len
())
}
}
impl
ToStr
for
~
str
{
#[inline(always)]
fn
to_str
(
&
self
)
->
~
str
{
to_owned
(
*
self
)
}
fn
to_str
(
&
self
)
->
~
str
{
self
.to_owned
(
)
}
}
impl
<
'self
>
ToStr
for
&
'self
str
{
#[inline(always)]
fn
to_str
(
&
self
)
->
~
str
{
to_owned
(
*
self
)
}
fn
to_str
(
&
self
)
->
~
str
{
self
.to_owned
(
)
}
}
impl
ToStr
for
@
str
{
#[inline(always)]
fn
to_str
(
&
self
)
->
~
str
{
to_owned
(
*
self
)
}
fn
to_str
(
&
self
)
->
~
str
{
self
.to_owned
(
)
}
}
/**
...
...
@@ -409,7 +403,7 @@ pub fn unshift_char(s: &mut ~str, ch: char) {
*/
pub
fn
to_bytes
(
s
:
&
str
)
->
~
[
u8
]
{
unsafe
{
let
mut
v
:
~
[
u8
]
=
::
cast
::
transmute
(
to_owned
(
s
));
let
mut
v
:
~
[
u8
]
=
::
cast
::
transmute
(
s
.to_owned
(
));
vec
::
raw
::
set_len
(
&
mut
v
,
s
.len
());
v
}
...
...
@@ -1237,7 +1231,7 @@ fn as_c_str<T>(self, f: &fn(*libc::c_char) -> T) -> T {
// NB: len includes the trailing null.
assert
!
(
len
>
0
);
if
unsafe
{
*
(
ptr
::
offset
(
buf
,
len
-
1
))
!=
0
}
{
to_owned
(
self
)
.as_c_str
(
f
)
self
.to_owned
(
)
.as_c_str
(
f
)
}
else
{
f
(
buf
as
*
libc
::
c_char
)
}
...
...
@@ -1526,7 +1520,9 @@ pub mod traits {
impl
<
'self
>
Add
<&
'self
str
,
~
str
>
for
~
str
{
#[inline(always)]
fn
add
(
&
self
,
rhs
:
&
&
'self
str
)
->
~
str
{
append
(
copy
*
self
,
(
*
rhs
))
let
mut
s
=
self
.to_owned
();
s
.push_str
(
*
rhs
);
s
}
}
}
...
...
@@ -1893,10 +1889,13 @@ fn trim_right_chars(&self, chars_to_trim: &[char]) -> &'self str {
}
}
/// Copy a slice into a new unique str
#[inline]
fn
to_owned
(
&
self
)
->
~
str
{
to_owned
(
*
self
)
}
fn
to_owned
(
&
self
)
->
~
str
{
unsafe
{
raw
::
slice_bytes_owned
(
*
self
,
0
,
self
.len
())
}
}
/// Copy a slice into a new @str
#[inline]
fn
to_managed
(
&
self
)
->
@
str
{
let
v
=
at_vec
::
from_fn
(
self
.len
()
+
1
,
|
i
|
{
...
...
@@ -2252,7 +2251,7 @@ fn reserve_at_least(&mut self, n: uint) {
impl
Clone
for
~
str
{
#[inline(always)]
fn
clone
(
&
self
)
->
~
str
{
to_owned
(
*
self
)
self
.to_owned
(
)
}
}
...
...
@@ -3135,6 +3134,11 @@ fn test_to_managed() {
assert_eq!
(
"abc"
.to_managed
(),
@
"abc"
);
assert_eq!
(
"abcdef"
.slice
(
1
,
5
)
.to_managed
(),
@
"bcde"
);
}
#[test]
fn
test_to_owned
()
{
assert_eq!
(
"abc"
.to_owned
(),
~
"abc"
);
assert_eq!
(
"abcdef"
.slice
(
1
,
5
)
.to_owned
(),
~
"bcde"
);
}
#[test]
fn
test_total_ord
()
{
...
...
src/libstd/vec.rs
浏览文件 @
96cd61ad
...
...
@@ -171,11 +171,6 @@ pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[T] {
}
}
/// Creates a new unique vector with the same contents as the slice
pub
fn
to_owned
<
T
:
Copy
>
(
t
:
&
[
T
])
->
~
[
T
]
{
from_fn
(
t
.len
(),
|
i
|
t
[
i
])
}
/// Creates a new vector with a capacity of `capacity`
pub
fn
with_capacity
<
T
>
(
capacity
:
uint
)
->
~
[
T
]
{
let
mut
vec
=
~
[];
...
...
@@ -1787,7 +1782,7 @@ pub trait CopyableVector<T> {
/// Extension methods for vectors
impl
<
'self
,
T
:
Copy
>
CopyableVector
<
T
>
for
&
'self
[
T
]
{
///
Returns a copy of `v`.
///
Creates a new unique vector with the same contents as the slice
#[inline]
fn
to_owned
(
&
self
)
->
~
[
T
]
{
let
mut
result
=
~
[];
...
...
@@ -1796,7 +1791,6 @@ fn to_owned(&self) -> ~[T] {
result
.push
(
copy
*
e
);
}
result
}
}
...
...
@@ -3361,19 +3355,19 @@ fn test_each_permutation() {
let
mut
results
:
~
[
~
[
int
]];
results
=
~
[];
for
each_permutation
([])
|
v
|
{
results
.push
(
to_owned
(
v
));
}
for
each_permutation
([])
|
v
|
{
results
.push
(
v
.to_owned
(
));
}
assert_eq!
(
results
,
~
[
~
[]]);
results
=
~
[];
for
each_permutation
([
7
])
|
v
|
{
results
.push
(
to_owned
(
v
));
}
for
each_permutation
([
7
])
|
v
|
{
results
.push
(
v
.to_owned
(
));
}
assert_eq!
(
results
,
~
[
~
[
7
]]);
results
=
~
[];
for
each_permutation
([
1
,
1
])
|
v
|
{
results
.push
(
to_owned
(
v
));
}
for
each_permutation
([
1
,
1
])
|
v
|
{
results
.push
(
v
.to_owned
(
));
}
assert_eq!
(
results
,
~
[
~
[
1
,
1
],
~
[
1
,
1
]]);
results
=
~
[];
for
each_permutation
([
5
,
2
,
0
])
|
v
|
{
results
.push
(
to_owned
(
v
));
}
for
each_permutation
([
5
,
2
,
0
])
|
v
|
{
results
.push
(
v
.to_owned
(
));
}
assert
!
(
results
==
~
[
~
[
5
,
2
,
0
],
~
[
5
,
0
,
2
],
~
[
2
,
5
,
0
],
~
[
2
,
0
,
5
],
~
[
0
,
5
,
2
],
~
[
0
,
2
,
5
]]);
}
...
...
src/libsyntax/attr.rs
浏览文件 @
96cd61ad
...
...
@@ -259,7 +259,7 @@ pub fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: &str)
pub
fn
sort_meta_items
(
items
:
&
[
@
ast
::
meta_item
])
->
~
[
@
ast
::
meta_item
]
{
// This is sort of stupid here, converting to a vec of mutables and back
let
mut
v
=
vec
::
to_owned
(
items
);
let
mut
v
=
items
.to_owned
(
);
do
extra
::
sort
::
quick_sort
(
v
)
|
ma
,
mb
|
{
get_meta_item_name
(
*
ma
)
<=
get_meta_item_name
(
*
mb
)
}
...
...
src/libsyntax/ext/asm.rs
浏览文件 @
96cd61ad
...
...
@@ -45,7 +45,7 @@ pub fn expand_asm(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
->
base
::
MacResult
{
let
p
=
parse
::
new_parser_from_tts
(
cx
.parse_sess
(),
cx
.cfg
(),
vec
::
to_owned
(
tts
));
tts
.to_owned
(
));
let
mut
asm
=
~
""
;
let
mut
outputs
=
~
[];
...
...
src/libsyntax/ext/base.rs
浏览文件 @
96cd61ad
...
...
@@ -367,7 +367,7 @@ pub fn get_exprs_from_tts(cx: @ExtCtxt, tts: &[ast::token_tree])
->
~
[
@
ast
::
expr
]
{
let
p
=
parse
::
new_parser_from_tts
(
cx
.parse_sess
(),
cx
.cfg
(),
vec
::
to_owned
(
tts
));
tts
.to_owned
(
));
let
mut
es
=
~
[];
while
*
p
.token
!=
token
::
EOF
{
if
es
.len
()
!=
0
{
...
...
src/libsyntax/ext/log_syntax.rs
浏览文件 @
96cd61ad
...
...
@@ -28,7 +28,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt,
cx
.print_backtrace
();
io
::
stdout
()
.write_line
(
print
::
pprust
::
tt_to_str
(
ast
::
tt_delim
(
vec
::
to_owned
(
tt
)),
ast
::
tt_delim
(
tt
.to_owned
(
)),
get_ident_interner
()));
//trivial expression
...
...
src/libsyntax/ext/quote.rs
浏览文件 @
96cd61ad
...
...
@@ -40,8 +40,6 @@ pub mod rt {
use
parse
;
use
print
::
pprust
;
use
core
::
str
;
pub
use
ast
::
*
;
pub
use
parse
::
token
::
*
;
pub
use
parse
::
new_parser_from_tts
;
...
...
@@ -128,7 +126,7 @@ fn to_source(&self) -> ~str {
impl
<
'self
>
ToSource
for
&
'self
str
{
fn
to_source
(
&
self
)
->
~
str
{
let
lit
=
dummy_spanned
(
ast
::
lit_str
(
@
s
tr
::
to_owned
(
*
self
)));
let
lit
=
dummy_spanned
(
ast
::
lit_str
(
@
s
elf
.to_owned
(
)));
pprust
::
lit_to_str
(
@
lit
)
}
}
...
...
@@ -661,7 +659,7 @@ fn expand_tts(cx: @ExtCtxt,
let
p
=
parse
::
new_parser_from_tts
(
cx
.parse_sess
(),
cx
.cfg
(),
vec
::
to_owned
(
tts
)
tts
.to_owned
(
)
);
*
p
.quote_depth
+=
1u
;
let
tts
=
p
.parse_all_token_trees
();
...
...
src/libsyntax/ext/trace_macros.rs
浏览文件 @
96cd61ad
...
...
@@ -29,7 +29,7 @@ pub fn expand_trace_macros(cx: @ExtCtxt,
let
tt_rdr
=
new_tt_reader
(
copy
cx
.parse_sess
()
.span_diagnostic
,
None
,
vec
::
to_owned
(
tt
)
tt
.to_owned
(
)
);
let
rdr
=
tt_rdr
as
@
reader
;
let
rust_parser
=
Parser
(
...
...
src/libsyntax/ext/tt/macro_rules.rs
浏览文件 @
96cd61ad
...
...
@@ -84,7 +84,7 @@ fn generic_extension(cx: @ExtCtxt, sp: span, name: ident,
io
::
println
(
fmt!
(
"%s! { %s }"
,
cx
.str_of
(
name
),
print
::
pprust
::
tt_to_str
(
ast
::
tt_delim
(
vec
::
to_owned
(
arg
)),
ast
::
tt_delim
(
arg
.to_owned
(
)),
get_ident_interner
())));
}
...
...
@@ -101,7 +101,7 @@ fn generic_extension(cx: @ExtCtxt, sp: span, name: ident,
let
arg_rdr
=
new_tt_reader
(
s_d
,
None
,
vec
::
to_owned
(
arg
)
arg
.to_owned
(
)
)
as
@
reader
;
match
parse
(
cx
.parse_sess
(),
cx
.cfg
(),
arg_rdr
,
*
mtcs
)
{
success
(
named_matches
)
=>
{
...
...
src/test/run-pass/struct-order-of-eval-1.rs
浏览文件 @
96cd61ad
...
...
@@ -14,5 +14,5 @@ struct S { f0: ~str, f1: int }
pub
fn
main
()
{
let
s
=
~
"Hello, world!"
;
let
_
s
=
S
{
f0
:
s
tr
::
to_owned
(
s
),
..
S
{
f0
:
s
,
f1
:
23
}
};
let
_
s
=
S
{
f0
:
s
.to_owned
(
),
..
S
{
f0
:
s
,
f1
:
23
}
};
}
src/test/run-pass/struct-order-of-eval-2.rs
浏览文件 @
96cd61ad
...
...
@@ -14,5 +14,5 @@ struct S { f0: ~str, f1: ~str }
pub
fn
main
()
{
let
s
=
~
"Hello, world!"
;
let
_
s
=
S
{
f1
:
s
tr
::
to_owned
(
s
),
f0
:
s
};
let
_
s
=
S
{
f1
:
s
.to_owned
(
),
f0
:
s
};
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录