Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b29cd22b
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,发现更多精彩内容 >>
提交
b29cd22b
编写于
6月 10, 2013
作者:
H
Huon Wilson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
std: replace str::all/any fns and methods with iterators
上级
1e8982bd
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
15 addition
and
60 deletion
+15
-60
src/compiletest/header.rs
src/compiletest/header.rs
+1
-0
src/compiletest/runtest.rs
src/compiletest/runtest.rs
+1
-1
src/libextra/json.rs
src/libextra/json.rs
+1
-1
src/libextra/semver.rs
src/libextra/semver.rs
+2
-1
src/librustdoc/unindent_pass.rs
src/librustdoc/unindent_pass.rs
+1
-1
src/libstd/path.rs
src/libstd/path.rs
+2
-2
src/libstd/run.rs
src/libstd/run.rs
+1
-1
src/libstd/str.rs
src/libstd/str.rs
+2
-50
src/libstd/str/ascii.rs
src/libstd/str/ascii.rs
+2
-2
src/libsyntax/parse/lexer.rs
src/libsyntax/parse/lexer.rs
+2
-1
未找到文件。
src/compiletest/header.rs
浏览文件 @
b29cd22b
...
...
@@ -13,6 +13,7 @@
use
common
::
config
;
use
common
;
use
core
::
iterator
::
IteratorUtil
;
use
core
::
io
;
use
core
::
os
;
use
core
::
str
;
...
...
src/compiletest/runtest.rs
浏览文件 @
b29cd22b
...
...
@@ -735,7 +735,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
let
cmdline
=
make_cmdline
(
""
,
args
.prog
,
args
.args
);
// get bare program string
let
tvec
:
~
[
~
str
]
=
args
.prog
.split_iter
(
'/'
)
.transform
(|
ts
|
ts
.to_owned
())
.collect
();
let
mut
tvec
:
~
[
~
str
]
=
args
.prog
.split_iter
(
'/'
)
.transform
(|
ts
|
ts
.to_owned
())
.collect
();
let
prog_short
=
tvec
.pop
();
// copy to target
...
...
src/libextra/json.rs
浏览文件 @
b29cd22b
...
...
@@ -567,7 +567,7 @@ fn parse_whitespace(&mut self) {
}
fn
parse_ident
(
&
mut
self
,
ident
:
&
str
,
value
:
Json
)
->
Result
<
Json
,
Error
>
{
if
str
::
all
(
ident
,
|
c
|
c
==
self
.next_char
())
{
if
ident
.iter
()
.all
(
|
c
|
c
==
self
.next_char
())
{
self
.bump
();
Ok
(
value
)
}
else
{
...
...
src/libextra/semver.rs
浏览文件 @
b29cd22b
...
...
@@ -14,6 +14,7 @@
use
core
::
prelude
::
*
;
use
core
::
iterator
::
IteratorUtil
;
use
core
::
char
;
use
core
::
cmp
;
use
core
::
io
::{
ReaderUtil
};
...
...
@@ -168,7 +169,7 @@ fn take_num(rdr: @io::Reader, ch: char) -> (uint, char) {
fn
take_ident
(
rdr
:
@
io
::
Reader
,
ch
:
char
)
->
(
Identifier
,
char
)
{
let
(
s
,
ch
)
=
take_nonempty_prefix
(
rdr
,
ch
,
char
::
is_alphanumeric
);
if
s
.all
(
char
::
is_digit
)
{
if
s
.
iter
()
.
all
(
char
::
is_digit
)
{
match
uint
::
from_str
(
s
)
{
None
=>
{
bad_parse
::
cond
.raise
(());
(
Numeric
(
0
),
ch
)
},
Some
(
i
)
=>
(
Numeric
(
i
),
ch
)
...
...
src/librustdoc/unindent_pass.rs
浏览文件 @
b29cd22b
...
...
@@ -63,7 +63,7 @@ fn unindent(s: &str) -> ~str {
}
else
{
saw_first_line
=
true
;
let
mut
spaces
=
0
;
do
str
::
all
(
*
line
)
|
char
|
{
do
line
.iter
()
.all
|
char
|
{
// Only comparing against space because I wouldn't
// know what to do with mixed whitespace chars
if
char
==
' '
{
...
...
src/libstd/path.rs
浏览文件 @
b29cd22b
...
...
@@ -508,7 +508,7 @@ fn with_dirname(&self, d: &str) -> PosixPath {
}
fn
with_filename
(
&
self
,
f
:
&
str
)
->
PosixPath
{
assert
!
(
!
str
::
any
(
f
,
|
c
|
windows
::
is_sep
(
c
)
));
assert
!
(
!
f
.iter
()
.all
(
windows
::
is_sep
));
self
.dir_path
()
.push
(
f
)
}
...
...
@@ -722,7 +722,7 @@ fn with_dirname(&self, d: &str) -> WindowsPath {
}
fn
with_filename
(
&
self
,
f
:
&
str
)
->
WindowsPath
{
assert
!
(
!
str
::
any
(
f
,
|
c
|
windows
::
is_sep
(
c
)
));
assert
!
(
!
f
.iter
()
.all
(
windows
::
is_sep
));
self
.dir_path
()
.push
(
f
)
}
...
...
src/libstd/run.rs
浏览文件 @
b29cd22b
...
...
@@ -588,7 +588,7 @@ pub fn make_command_line(prog: &str, args: &[~str]) -> ~str {
return
cmd
;
fn
append_arg
(
cmd
:
&
mut
~
str
,
arg
:
&
str
)
{
let
quote
=
arg
.any
(|
c
|
c
==
' '
||
c
==
'\t'
);
let
quote
=
arg
.
iter
()
.
any
(|
c
|
c
==
' '
||
c
==
'\t'
);
if
quote
{
cmd
.push_char
(
'"'
);
}
...
...
src/libstd/str.rs
浏览文件 @
b29cd22b
...
...
@@ -1175,22 +1175,6 @@ fn equiv(&self, other: &~str) -> bool { eq_slice(*self, *other) }
Section: Iterating through strings
*/
/**
* Return true if a predicate matches all characters or if the string
* contains no characters
*/
pub
fn
all
(
s
:
&
str
,
it
:
&
fn
(
char
)
->
bool
)
->
bool
{
all_between
(
s
,
0u
,
len
(
s
),
it
)
}
/**
* Return true if a predicate matches any character (and false if it
* matches none or there are no characters)
*/
pub
fn
any
(
ss
:
&
str
,
pred
:
&
fn
(
char
)
->
bool
)
->
bool
{
!
all
(
ss
,
|
cc
|
!
pred
(
cc
))
}
/// Apply a function to each character
pub
fn
map
(
ss
:
&
str
,
ff
:
&
fn
(
char
)
->
char
)
->
~
str
{
let
mut
result
=
~
""
;
...
...
@@ -1675,7 +1659,7 @@ pub fn is_empty(s: &str) -> bool { len(s) == 0u }
* Whitespace characters are determined by `char::is_whitespace`
*/
pub
fn
is_whitespace
(
s
:
&
str
)
->
bool
{
return
all
(
s
,
char
::
is_whitespace
);
s
.iter
()
.all
(
char
::
is_whitespace
)
}
/**
...
...
@@ -1684,7 +1668,7 @@ pub fn is_whitespace(s: &str) -> bool {
* Alphanumeric characters are determined by `char::is_alphanumeric`
*/
fn
is_alphanumeric
(
s
:
&
str
)
->
bool
{
return
all
(
s
,
char
::
is_alphanumeric
);
s
.iter
()
.all
(
char
::
is_alphanumeric
)
}
/// Returns the string length/size in bytes not counting the null terminator
...
...
@@ -2467,8 +2451,6 @@ pub mod traits {}
#[allow(missing_doc)]
pub
trait
StrSlice
<
'self
>
{
fn
all
(
&
self
,
it
:
&
fn
(
char
)
->
bool
)
->
bool
;
fn
any
(
&
self
,
it
:
&
fn
(
char
)
->
bool
)
->
bool
;
fn
contains
<
'a
>
(
&
self
,
needle
:
&
'a
str
)
->
bool
;
fn
contains_char
(
&
self
,
needle
:
char
)
->
bool
;
fn
iter
(
&
self
)
->
StrCharIterator
<
'self
>
;
...
...
@@ -2514,18 +2496,6 @@ fn split_options_iter<Sep: StrCharSplitSeparator>(&self, sep: Sep,
/// Extension methods for strings
impl
<
'self
>
StrSlice
<
'self
>
for
&
'self
str
{
/**
* Return true if a predicate matches all characters or if the string
* contains no characters
*/
#[inline]
fn
all
(
&
self
,
it
:
&
fn
(
char
)
->
bool
)
->
bool
{
all
(
*
self
,
it
)
}
/**
* Return true if a predicate matches any character (and false if it
* matches none or there are no characters)
*/
#[inline]
fn
any
(
&
self
,
it
:
&
fn
(
char
)
->
bool
)
->
bool
{
any
(
*
self
,
it
)
}
/// Returns true if one string contains another
#[inline]
fn
contains
<
'a
>
(
&
self
,
needle
:
&
'a
str
)
->
bool
{
...
...
@@ -3522,24 +3492,6 @@ fn test_map() {
assert_eq!
(
~
"YMCA"
,
map
(
"ymca"
,
|
c
|
unsafe
{
libc
::
toupper
(
c
as
c_char
)}
as
char
));
}
#[test]
fn
test_all
()
{
assert_eq!
(
true
,
all
(
""
,
char
::
is_uppercase
));
assert_eq!
(
false
,
all
(
"ymca"
,
char
::
is_uppercase
));
assert_eq!
(
true
,
all
(
"YMCA"
,
char
::
is_uppercase
));
assert_eq!
(
false
,
all
(
"yMCA"
,
char
::
is_uppercase
));
assert_eq!
(
false
,
all
(
"YMCy"
,
char
::
is_uppercase
));
}
#[test]
fn
test_any
()
{
assert_eq!
(
false
,
any
(
""
,
char
::
is_uppercase
));
assert_eq!
(
false
,
any
(
"ymca"
,
char
::
is_uppercase
));
assert_eq!
(
true
,
any
(
"YMCA"
,
char
::
is_uppercase
));
assert_eq!
(
true
,
any
(
"yMCA"
,
char
::
is_uppercase
));
assert_eq!
(
true
,
any
(
"Ymcy"
,
char
::
is_uppercase
));
}
#[test]
fn
test_chars
()
{
let
ss
=
~
"ศไทย中华Việt Nam"
;
...
...
src/libstd/str/ascii.rs
浏览文件 @
b29cd22b
...
...
@@ -226,8 +226,8 @@ fn test_ascii() {
assert_eq!
(
'`'
.to_ascii
()
.to_upper
()
.to_char
(),
'`'
);
assert_eq!
(
'{'
.to_ascii
()
.to_upper
()
.to_char
(),
'{'
);
assert
!
(
str
::
all
(
"banana"
,
|
c
|
c
.is_ascii
()));
assert
!
(
!
str
::
all
(
"ประเทศไทย中华Việt Nam"
,
|
c
|
c
.is_ascii
()));
assert
!
(
"banana"
.iter
()
.all
(
|
c
|
c
.is_ascii
()));
assert
!
(
!
"ประเทศไทย中华Việt Nam"
.iter
()
.all
(
|
c
|
c
.is_ascii
()));
}
#[test]
...
...
src/libsyntax/parse/lexer.rs
浏览文件 @
b29cd22b
...
...
@@ -19,6 +19,7 @@
use
parse
::
token
;
use
parse
::
token
::{
str_to_ident
};
use
core
::
iterator
::
IteratorUtil
;
use
core
::
char
;
use
core
::
either
;
use
core
::
str
;
...
...
@@ -245,7 +246,7 @@ fn consume_whitespace_and_comments(rdr: @mut StringReader)
pub
fn
is_line_non_doc_comment
(
s
:
&
str
)
->
bool
{
let
s
=
s
.trim_right
();
s
.len
()
>
3
&&
s
.all
(|
ch
|
ch
==
'/'
)
s
.len
()
>
3
&&
s
.
iter
()
.
all
(|
ch
|
ch
==
'/'
)
}
// PRECONDITION: rdr.curr is not whitespace
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录