Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5928f6c8
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,发现更多精彩内容 >>
提交
5928f6c8
编写于
10月 13, 2014
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix various deprecation warnings from char changes
上级
b577e4c8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
75 addition
and
65 deletion
+75
-65
src/libcore/char.rs
src/libcore/char.rs
+66
-56
src/libcore/fmt/float.rs
src/libcore/fmt/float.rs
+2
-1
src/libfmt_macros/lib.rs
src/libfmt_macros/lib.rs
+1
-1
src/libstd/num/strconv.rs
src/libstd/num/strconv.rs
+2
-1
src/libsyntax/parse/lexer/mod.rs
src/libsyntax/parse/lexer/mod.rs
+3
-3
src/libterm/terminfo/parm.rs
src/libterm/terminfo/parm.rs
+1
-3
未找到文件。
src/libcore/char.rs
浏览文件 @
5928f6c8
...
...
@@ -100,10 +100,7 @@ pub fn from_u32(i: u32) -> Option<char> {
#[inline]
#[deprecated
=
"use the Char::is_digit method"
]
pub
fn
is_digit_radix
(
c
:
char
,
radix
:
uint
)
->
bool
{
match
to_digit
(
c
,
radix
)
{
Some
(
_
)
=>
true
,
None
=>
false
,
}
c
.is_digit
(
radix
)
}
///
...
...
@@ -123,17 +120,7 @@ pub fn is_digit_radix(c: char, radix: uint) -> bool {
#[inline]
#[deprecated
=
"use the Char::to_digit method"
]
pub
fn
to_digit
(
c
:
char
,
radix
:
uint
)
->
Option
<
uint
>
{
if
radix
>
36
{
panic!
(
"to_digit: radix is too high (maximum 36)"
);
}
let
val
=
match
c
{
'0'
...
'9'
=>
c
as
uint
-
(
'0'
as
uint
),
'a'
...
'z'
=>
c
as
uint
+
10u
-
(
'a'
as
uint
),
'A'
...
'Z'
=>
c
as
uint
+
10u
-
(
'A'
as
uint
),
_
=>
return
None
,
};
if
val
<
radix
{
Some
(
val
)
}
else
{
None
}
c
.to_digit
(
radix
)
}
///
...
...
@@ -178,23 +165,7 @@ pub fn from_digit(num: uint, radix: uint) -> Option<char> {
///
#[deprecated
=
"use the Char::escape_unicode method"
]
pub
fn
escape_unicode
(
c
:
char
,
f
:
|
char
|)
{
// avoid calling str::to_str_radix because we don't really need to allocate
// here.
f
(
'\\'
);
let
pad
=
match
()
{
_
if
c
<=
'\x7f'
=>
{
f
(
'x'
);
2
}
_
if
c
<=
'\uffff'
=>
{
f
(
'u'
);
4
}
_
=>
{
f
(
'U'
);
8
}
};
for
offset
in
range_step
::
<
i32
>
(
4
*
(
pad
-
1
),
-
1
,
-
4
)
{
let
offset
=
offset
as
uint
;
unsafe
{
match
((
c
as
i32
)
>>
offset
)
&
0xf
{
i
@
0
...
9
=>
{
f
(
transmute
(
'0'
as
i32
+
i
));
}
i
=>
{
f
(
transmute
(
'a'
as
i32
+
(
i
-
10
)));
}
}
}
}
c
.escape_unicode
(
f
)
}
///
...
...
@@ -211,29 +182,14 @@ pub fn escape_unicode(c: char, f: |char|) {
///
#[deprecated
=
"use the Char::escape_default method"
]
pub
fn
escape_default
(
c
:
char
,
f
:
|
char
|)
{
match
c
{
'\t'
=>
{
f
(
'\\'
);
f
(
't'
);
}
'\r'
=>
{
f
(
'\\'
);
f
(
'r'
);
}
'\n'
=>
{
f
(
'\\'
);
f
(
'n'
);
}
'\\'
=>
{
f
(
'\\'
);
f
(
'\\'
);
}
'\''
=>
{
f
(
'\\'
);
f
(
'\''
);
}
'"'
=>
{
f
(
'\\'
);
f
(
'"'
);
}
'\x20'
...
'\x7e'
=>
{
f
(
c
);
}
_
=>
c
.escape_unicode
(
f
),
}
c
.escape_default
(
f
)
}
/// Returns the amount of bytes this `char` would need if encoded in UTF-8
#[inline]
#[deprecated
=
"use the Char::len_utf8 method"
]
pub
fn
len_utf8_bytes
(
c
:
char
)
->
uint
{
let
code
=
c
as
u32
;
match
()
{
_
if
code
<
MAX_ONE_B
=>
1u
,
_
if
code
<
MAX_TWO_B
=>
2u
,
_
if
code
<
MAX_THREE_B
=>
3u
,
_
=>
4u
,
}
c
.len_utf8
()
}
/// Basic `char` manipulations.
...
...
@@ -362,13 +318,30 @@ pub trait Char {
#[experimental
=
"trait is experimental"
]
impl
Char
for
char
{
#[deprecated
=
"use is_digit"
]
fn
is_digit_radix
(
&
self
,
radix
:
uint
)
->
bool
{
is_digit_radix
(
*
self
,
radix
)
}
fn
is_digit_radix
(
&
self
,
radix
:
uint
)
->
bool
{
self
.is_digit
(
radix
)
}
#[unstable
=
"pending trait organization"
]
fn
is_digit
(
&
self
,
radix
:
uint
)
->
bool
{
is_digit_radix
(
*
self
,
radix
)
}
fn
is_digit
(
&
self
,
radix
:
uint
)
->
bool
{
match
self
.to_digit
(
radix
)
{
Some
(
_
)
=>
true
,
None
=>
false
,
}
}
#[unstable
=
"pending trait organization"
]
fn
to_digit
(
&
self
,
radix
:
uint
)
->
Option
<
uint
>
{
to_digit
(
*
self
,
radix
)
}
fn
to_digit
(
&
self
,
radix
:
uint
)
->
Option
<
uint
>
{
if
radix
>
36
{
panic!
(
"to_digit: radix is too high (maximum 36)"
);
}
let
val
=
match
*
self
{
'0'
...
'9'
=>
*
self
as
uint
-
(
'0'
as
uint
),
'a'
...
'z'
=>
*
self
as
uint
+
10u
-
(
'a'
as
uint
),
'A'
...
'Z'
=>
*
self
as
uint
+
10u
-
(
'A'
as
uint
),
_
=>
return
None
,
};
if
val
<
radix
{
Some
(
val
)
}
else
{
None
}
}
#[deprecated
=
"use the char::from_digit free function"
]
fn
from_digit
(
num
:
uint
,
radix
:
uint
)
->
Option
<
char
>
{
from_digit
(
num
,
radix
)
}
...
...
@@ -378,18 +351,55 @@ fn from_digit(num: uint, radix: uint) -> Option<char> { from_digit(num, radix) }
fn
from_u32
(
i
:
u32
)
->
Option
<
char
>
{
from_u32
(
i
)
}
#[unstable
=
"pending error conventions, trait organization"
]
fn
escape_unicode
(
&
self
,
f
:
|
char
|)
{
escape_unicode
(
*
self
,
f
)
}
fn
escape_unicode
(
&
self
,
f
:
|
char
|)
{
// avoid calling str::to_str_radix because we don't really need to allocate
// here.
f
(
'\\'
);
let
pad
=
match
()
{
_
if
*
self
<=
'\xff'
=>
{
f
(
'x'
);
2
}
_
if
*
self
<=
'\uffff'
=>
{
f
(
'u'
);
4
}
_
=>
{
f
(
'U'
);
8
}
};
for
offset
in
range_step
::
<
i32
>
(
4
*
(
pad
-
1
),
-
1
,
-
4
)
{
let
offset
=
offset
as
uint
;
unsafe
{
match
((
*
self
as
i32
)
>>
offset
)
&
0xf
{
i
@
0
...
9
=>
{
f
(
transmute
(
'0'
as
i32
+
i
));
}
i
=>
{
f
(
transmute
(
'a'
as
i32
+
(
i
-
10
)));
}
}
}
}
}
#[unstable
=
"pending error conventions, trait organization"
]
fn
escape_default
(
&
self
,
f
:
|
char
|)
{
escape_default
(
*
self
,
f
)
}
fn
escape_default
(
&
self
,
f
:
|
char
|)
{
match
*
self
{
'\t'
=>
{
f
(
'\\'
);
f
(
't'
);
}
'\r'
=>
{
f
(
'\\'
);
f
(
'r'
);
}
'\n'
=>
{
f
(
'\\'
);
f
(
'n'
);
}
'\\'
=>
{
f
(
'\\'
);
f
(
'\\'
);
}
'\''
=>
{
f
(
'\\'
);
f
(
'\''
);
}
'"'
=>
{
f
(
'\\'
);
f
(
'"'
);
}
'\x20'
...
'\x7e'
=>
{
f
(
*
self
);
}
_
=>
self
.escape_unicode
(
f
),
}
}
#[inline]
#[deprecated
=
"use len_utf8"
]
fn
len_utf8_bytes
(
&
self
)
->
uint
{
len_utf8_bytes
(
*
self
)
}
fn
len_utf8_bytes
(
&
self
)
->
uint
{
self
.len_utf8
(
)
}
#[inline]
#[unstable
=
"pending trait organization"
]
fn
len_utf8
(
&
self
)
->
uint
{
len_utf8_bytes
(
*
self
)
}
fn
len_utf8
(
&
self
)
->
uint
{
let
code
=
*
self
as
u32
;
match
()
{
_
if
code
<
MAX_ONE_B
=>
1u
,
_
if
code
<
MAX_TWO_B
=>
2u
,
_
if
code
<
MAX_THREE_B
=>
3u
,
_
=>
4u
,
}
}
#[inline]
#[unstable
=
"pending trait organization"
]
...
...
src/libcore/fmt/float.rs
浏览文件 @
5928f6c8
...
...
@@ -15,6 +15,7 @@
pub
use
self
::
SignFormat
::
*
;
use
char
;
use
char
::
Char
;
use
fmt
;
use
iter
::{
range
,
DoubleEndedIterator
};
use
num
::{
Float
,
FPNaN
,
FPInfinite
,
ToPrimitive
};
...
...
@@ -222,7 +223,7 @@ pub fn float_to_str_bytes_common<T: Float, U>(
// round the remaining ones.
if
limit_digits
&&
dig
==
digit_count
{
let
ascii2value
=
|
chr
:
u8
|
{
char
::
to_digit
(
chr
as
char
,
radix
)
.unwrap
()
(
chr
as
char
)
.to_digit
(
radix
)
.unwrap
()
};
let
value2ascii
=
|
val
:
uint
|
{
char
::
from_digit
(
val
,
radix
)
.unwrap
()
as
u8
...
...
src/libfmt_macros/lib.rs
浏览文件 @
5928f6c8
...
...
@@ -411,7 +411,7 @@ fn integer(&mut self) -> Option<uint> {
loop
{
match
self
.cur
.clone
()
.next
()
{
Some
((
_
,
c
))
=>
{
match
c
har
::
to_digit
(
c
,
10
)
{
match
c
.to_digit
(
10
)
{
Some
(
i
)
=>
{
cur
=
cur
*
10
+
i
;
found
=
true
;
...
...
src/libstd/num/strconv.rs
浏览文件 @
5928f6c8
...
...
@@ -17,6 +17,7 @@
pub
use
self
::
SignFormat
::
*
;
use
char
;
use
char
::
Char
;
use
num
;
use
num
::{
Int
,
Float
,
FPNaN
,
FPInfinite
,
ToPrimitive
};
use
slice
::{
SlicePrelude
,
CloneSliceAllocPrelude
};
...
...
@@ -320,7 +321,7 @@ pub fn float_to_str_bytes_common<T: Float>(
// round the remaining ones.
if
limit_digits
&&
dig
==
digit_count
{
let
ascii2value
=
|
chr
:
u8
|
{
char
::
to_digit
(
chr
as
char
,
radix
)
.unwrap
()
(
chr
as
char
)
.to_digit
(
radix
)
.unwrap
()
};
let
value2ascii
=
|
val
:
uint
|
{
char
::
from_digit
(
val
,
radix
)
.unwrap
()
as
u8
...
...
src/libsyntax/parse/lexer/mod.rs
浏览文件 @
5928f6c8
...
...
@@ -645,7 +645,7 @@ fn scan_digits(&mut self, radix: uint) -> uint {
loop
{
let
c
=
self
.curr
;
if
c
==
Some
(
'_'
)
{
debug!
(
"skipping a _"
);
self
.bump
();
continue
;
}
match
c
.and_then
(|
cc
|
c
har
::
to_digit
(
cc
,
radix
))
{
match
c
.and_then
(|
cc
|
c
c
.to_digit
(
radix
))
{
Some
(
_
)
=>
{
debug!
(
"{} in scan_digits"
,
c
);
len
+=
1
;
...
...
@@ -677,7 +677,7 @@ fn scan_number(&mut self, c: char) -> token::Lit {
return
token
::
Integer
(
self
.name_from
(
start_bpos
));
}
}
}
else
if
c
.is_digit
_radix
(
10
)
{
}
else
if
c
.is_digit
(
10
)
{
num_digits
=
self
.scan_digits
(
10
)
+
1
;
}
else
{
num_digits
=
0
;
...
...
@@ -696,7 +696,7 @@ fn scan_number(&mut self, c: char) -> token::Lit {
// might have stuff after the ., and if it does, it needs to start
// with a number
self
.bump
();
if
self
.curr
.unwrap_or
(
'\0'
)
.is_digit
_radix
(
10
)
{
if
self
.curr
.unwrap_or
(
'\0'
)
.is_digit
(
10
)
{
self
.scan_digits
(
10
);
self
.scan_float_exponent
();
}
...
...
src/libterm/terminfo/parm.rs
浏览文件 @
5928f6c8
...
...
@@ -14,8 +14,6 @@
use
self
::
States
::
*
;
use
self
::
FormatState
::
*
;
use
self
::
FormatOp
::
*
;
use
std
::
char
;
use
std
::
mem
::
replace
;
#[deriving(PartialEq)]
...
...
@@ -298,7 +296,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
},
PushParam
=>
{
// params are 1-indexed
stack
.push
(
mparams
[
match
c
har
::
to_digit
(
cur
,
10
)
{
stack
.push
(
mparams
[
match
c
ur
.to_digit
(
10
)
{
Some
(
d
)
=>
d
-
1
,
None
=>
return
Err
(
"bad param number"
.to_string
())
}]
.clone
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录