Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
cda1d352
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,发现更多精彩内容 >>
提交
cda1d352
编写于
9月 27, 2012
作者:
G
Graydon Hoare
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Finish de-exporting box, char, float. Part of #3583.
上级
3dd87689
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
52 deletion
+25
-52
src/libcore/char.rs
src/libcore/char.rs
+10
-18
src/libcore/core.rc
src/libcore/core.rc
+0
-3
src/libcore/float.rs
src/libcore/float.rs
+15
-31
未找到文件。
src/libcore/char.rs
浏览文件 @
cda1d352
...
...
@@ -39,14 +39,6 @@
Cn Unassigned a reserved unassigned code point or a noncharacter
*/
export
is_alphabetic
,
is_XID_start
,
is_XID_continue
,
is_lowercase
,
is_uppercase
,
is_whitespace
,
is_alphanumeric
,
is_ascii
,
is_digit
,
to_digit
,
cmp
,
escape_default
,
escape_unicode
;
pub
use
is_alphabetic
=
unicode
::
derived_property
::
Alphabetic
;
pub
use
is_XID_start
=
unicode
::
derived_property
::
XID_Start
;
pub
use
is_XID_continue
=
unicode
::
derived_property
::
XID_Continue
;
...
...
@@ -56,7 +48,7 @@
* Indicates whether a character is in lower case, defined
* in terms of the Unicode General Category 'Ll'
*/
pure
fn
is_lowercase
(
c
:
char
)
->
bool
{
pu
b
pu
re
fn
is_lowercase
(
c
:
char
)
->
bool
{
return
unicode
::
general_category
::
Ll
(
c
);
}
...
...
@@ -64,7 +56,7 @@
* Indicates whether a character is in upper case, defined
* in terms of the Unicode General Category 'Lu'.
*/
pure
fn
is_uppercase
(
c
:
char
)
->
bool
{
pu
b
pu
re
fn
is_uppercase
(
c
:
char
)
->
bool
{
return
unicode
::
general_category
::
Lu
(
c
);
}
...
...
@@ -73,7 +65,7 @@
* terms of the Unicode General Categories 'Zs', 'Zl', 'Zp'
* additional 'Cc'-category control codes in the range [0x09, 0x0d]
*/
pure
fn
is_whitespace
(
c
:
char
)
->
bool
{
pu
b
pu
re
fn
is_whitespace
(
c
:
char
)
->
bool
{
return
(
'\x09'
<=
c
&&
c
<=
'\x0d'
)
||
unicode
::
general_category
::
Zs
(
c
)
||
unicode
::
general_category
::
Zl
(
c
)
...
...
@@ -85,7 +77,7 @@
* defined in terms of the Unicode General Categories 'Nd', 'Nl', 'No'
* and the Derived Core Property 'Alphabetic'.
*/
pure
fn
is_alphanumeric
(
c
:
char
)
->
bool
{
pu
b
pu
re
fn
is_alphanumeric
(
c
:
char
)
->
bool
{
return
unicode
::
derived_property
::
Alphabetic
(
c
)
||
unicode
::
general_category
::
Nd
(
c
)
||
unicode
::
general_category
::
Nl
(
c
)
||
...
...
@@ -93,12 +85,12 @@
}
/// Indicates whether the character is an ASCII character
pure
fn
is_ascii
(
c
:
char
)
->
bool
{
pu
b
pu
re
fn
is_ascii
(
c
:
char
)
->
bool
{
c
-
(
'\x7F'
&
c
)
==
'\x00'
}
/// Indicates whether the character is numeric (Nd, Nl, or No)
pure
fn
is_digit
(
c
:
char
)
->
bool
{
pu
b
pu
re
fn
is_digit
(
c
:
char
)
->
bool
{
return
unicode
::
general_category
::
Nd
(
c
)
||
unicode
::
general_category
::
Nl
(
c
)
||
unicode
::
general_category
::
No
(
c
);
...
...
@@ -114,7 +106,7 @@
* 'b' or 'B', 11, etc. Returns none if the char does not
* refer to a digit in the given radix.
*/
pure
fn
to_digit
(
c
:
char
,
radix
:
uint
)
->
Option
<
uint
>
{
pu
b
pu
re
fn
to_digit
(
c
:
char
,
radix
:
uint
)
->
Option
<
uint
>
{
let
val
=
match
c
{
'0'
..
'9'
=>
c
as
uint
-
(
'0'
as
uint
),
'a'
..
'z'
=>
c
as
uint
+
10u
-
(
'a'
as
uint
),
...
...
@@ -134,7 +126,7 @@
* - chars in [0x100,0xffff] get 4-digit escapes: `\\uNNNN`
* - chars above 0x10000 get 8-digit escapes: `\\UNNNNNNNN`
*/
fn
escape_unicode
(
c
:
char
)
->
~
str
{
pub
fn
escape_unicode
(
c
:
char
)
->
~
str
{
let
s
=
u32
::
to_str
(
c
as
u32
,
16u
);
let
(
c
,
pad
)
=
(
if
c
<=
'\xff'
{
(
'x'
,
2u
)
}
else
if
c
<=
'\uffff'
{
(
'u'
,
4u
)
}
...
...
@@ -159,7 +151,7 @@ fn escape_unicode(c: char) -> ~str {
* - Any other chars in the range [0x20,0x7e] are not escaped.
* - Any other chars are given hex unicode escapes; see `escape_unicode`.
*/
fn
escape_default
(
c
:
char
)
->
~
str
{
pub
fn
escape_default
(
c
:
char
)
->
~
str
{
match
c
{
'\t'
=>
~
"
\\
t"
,
'\r'
=>
~
"
\\
r"
,
...
...
@@ -179,7 +171,7 @@ fn escape_default(c: char) -> ~str {
*
* -1 if a < b, 0 if a == b, +1 if a > b
*/
pure
fn
cmp
(
a
:
char
,
b
:
char
)
->
int
{
pu
b
pu
re
fn
cmp
(
a
:
char
,
b
:
char
)
->
int
{
return
if
b
>
a
{
-
1
}
else
if
b
<
a
{
1
}
else
{
0
}
...
...
src/libcore/core.rc
浏览文件 @
cda1d352
...
...
@@ -196,11 +196,8 @@ mod u64 {
}
#[legacy_exports]
mod box;
#[legacy_exports]
mod char;
#[legacy_exports]
mod float;
#[legacy_exports]
mod f32;
...
...
src/libcore/float.rs
浏览文件 @
cda1d352
...
...
@@ -7,26 +7,10 @@
// Even though this module exports everything defined in it,
// because it contains re-exports, we also have to explicitly
// export locally defined things. That's a bit annoying.
export
to_str_common
,
to_str_exact
,
to_str
,
from_str
;
export
add
,
sub
,
mul
,
div
,
rem
,
lt
,
le
,
eq
,
ne
,
ge
,
gt
;
export
is_positive
,
is_negative
,
is_nonpositive
,
is_nonnegative
;
export
is_zero
,
is_infinite
,
is_finite
;
export
NaN
,
is_NaN
,
infinity
,
neg_infinity
;
export
consts
;
export
logarithm
;
export
acos
,
asin
,
atan
,
atan2
,
cbrt
,
ceil
,
copysign
,
cos
,
cosh
,
floor
;
export
erf
,
erfc
,
exp
,
expm1
,
exp2
,
abs
,
abs_sub
;
export
mul_add
,
fmax
,
fmin
,
nextafter
,
frexp
,
hypot
,
ldexp
;
export
lgamma
,
ln
,
log_radix
,
ln1p
,
log10
,
log2
,
ilog_radix
;
export
modf
,
pow
,
round
,
sin
,
sinh
,
sqrt
,
tan
,
tanh
,
tgamma
,
trunc
;
export
signbit
;
export
pow_with_uint
;
export
num
;
// export when m_float == c_double
export
j0
,
j1
,
jn
,
y0
,
y1
,
yn
;
// PORT this must match in width according to architecture
...
...
@@ -44,11 +28,11 @@
use
cmp
::{
Eq
,
Ord
};
use
num
::
from_int
;
const
NaN
:
float
=
0.0
/
0.0
;
pub
const
NaN
:
float
=
0.0
/
0.0
;
const
infinity
:
float
=
1.0
/
0.0
;
pub
const
infinity
:
float
=
1.0
/
0.0
;
const
neg_infinity
:
float
=
-
1.0
/
0.0
;
pub
const
neg_infinity
:
float
=
-
1.0
/
0.0
;
/* Module: consts */
pub
mod
consts
{
...
...
@@ -107,7 +91,7 @@ pub mod consts {
* * digits - The number of significant digits
* * exact - Whether to enforce the exact number of significant digits
*/
fn
to_str_common
(
num
:
float
,
digits
:
uint
,
exact
:
bool
)
->
~
str
{
pub
fn
to_str_common
(
num
:
float
,
digits
:
uint
,
exact
:
bool
)
->
~
str
{
if
is_NaN
(
num
)
{
return
~
"NaN"
;
}
if
num
==
infinity
{
return
~
"inf"
;
}
if
num
==
neg_infinity
{
return
~
"-inf"
;
}
...
...
@@ -414,22 +398,22 @@ pub fn pow_with_uint(base: uint, pow: uint) -> float {
pub
pure
fn
tan
(
x
:
float
)
->
float
{
f64
::
tan
(
x
as
f64
)
as
float
}
impl
float
:
Eq
{
pure
fn
eq
(
other
:
&
float
)
->
bool
{
self
==
(
*
other
)
}
pure
fn
ne
(
other
:
&
float
)
->
bool
{
self
!=
(
*
other
)
}
pu
b
pu
re
fn
eq
(
other
:
&
float
)
->
bool
{
self
==
(
*
other
)
}
pu
b
pu
re
fn
ne
(
other
:
&
float
)
->
bool
{
self
!=
(
*
other
)
}
}
impl
float
:
Ord
{
pure
fn
lt
(
other
:
&
float
)
->
bool
{
self
<
(
*
other
)
}
pure
fn
le
(
other
:
&
float
)
->
bool
{
self
<=
(
*
other
)
}
pure
fn
ge
(
other
:
&
float
)
->
bool
{
self
>=
(
*
other
)
}
pure
fn
gt
(
other
:
&
float
)
->
bool
{
self
>
(
*
other
)
}
pu
b
pu
re
fn
lt
(
other
:
&
float
)
->
bool
{
self
<
(
*
other
)
}
pu
b
pu
re
fn
le
(
other
:
&
float
)
->
bool
{
self
<=
(
*
other
)
}
pu
b
pu
re
fn
ge
(
other
:
&
float
)
->
bool
{
self
>=
(
*
other
)
}
pu
b
pu
re
fn
gt
(
other
:
&
float
)
->
bool
{
self
>
(
*
other
)
}
}
impl
float
:
num
::
Num
{
pure
fn
add
(
other
:
&
float
)
->
float
{
return
self
+
*
other
;
}
pure
fn
sub
(
other
:
&
float
)
->
float
{
return
self
-
*
other
;
}
pure
fn
mul
(
other
:
&
float
)
->
float
{
return
self
*
*
other
;
}
pure
fn
div
(
other
:
&
float
)
->
float
{
return
self
/
*
other
;
}
pu
b
pu
re
fn
add
(
other
:
&
float
)
->
float
{
return
self
+
*
other
;
}
pu
b
pu
re
fn
sub
(
other
:
&
float
)
->
float
{
return
self
-
*
other
;
}
pu
b
pu
re
fn
mul
(
other
:
&
float
)
->
float
{
return
self
*
*
other
;
}
pu
b
pu
re
fn
div
(
other
:
&
float
)
->
float
{
return
self
/
*
other
;
}
pure
fn
modulo
(
other
:
&
float
)
->
float
{
return
self
%
*
other
;
}
pure
fn
neg
()
->
float
{
return
-
self
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录