Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c2bc59e0
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,发现更多精彩内容 >>
提交
c2bc59e0
编写于
8月 26, 2013
作者:
D
Daniel Micay
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
repr: print integer/float suffixes
上级
20567a0c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
52 addition
and
37 deletion
+52
-37
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+6
-6
src/libstd/repr.rs
src/libstd/repr.rs
+40
-25
src/test/run-pass/fixed_length_vec_glue.rs
src/test/run-pass/fixed_length_vec_glue.rs
+1
-1
src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
+1
-1
src/test/run-pass/log-knows-the-names-of-variants.rs
src/test/run-pass/log-knows-the-names-of-variants.rs
+1
-1
src/test/run-pass/rec-align-u32.rs
src/test/run-pass/rec-align-u32.rs
+1
-1
src/test/run-pass/rec-align-u64.rs
src/test/run-pass/rec-align-u64.rs
+1
-1
src/test/run-pass/tag-align-shape.rs
src/test/run-pass/tag-align-shape.rs
+1
-1
未找到文件。
src/librustc/middle/ty.rs
浏览文件 @
c2bc59e0
...
...
@@ -3476,18 +3476,18 @@ fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> ~str {
terr_ptr_mutability
=>
~
"pointers differ in mutability"
,
terr_ref_mutability
=>
~
"references differ in mutability"
,
terr_ty_param_size
(
values
)
=>
{
fmt!
(
"expected a type with %
?
type params
\
but found one with %
?
type params"
,
fmt!
(
"expected a type with %
u
type params
\
but found one with %
u
type params"
,
values
.expected
,
values
.found
)
}
terr_tuple_size
(
values
)
=>
{
fmt!
(
"expected a tuple with %
?
elements
\
but found one with %
?
elements"
,
fmt!
(
"expected a tuple with %
u
elements
\
but found one with %
u
elements"
,
values
.expected
,
values
.found
)
}
terr_record_size
(
values
)
=>
{
fmt!
(
"expected a record with %
?
fields
\
but found one with %
?
fields"
,
fmt!
(
"expected a record with %
u
fields
\
but found one with %
u
fields"
,
values
.expected
,
values
.found
)
}
terr_record_mutability
=>
{
...
...
src/libstd/repr.rs
浏览文件 @
c2bc59e0
...
...
@@ -75,35 +75,50 @@ fn write_repr(&self, writer: @Writer) {
}
}
macro_rules!
int_repr
((
$ty:ident
)
=>
(
impl
Repr
for
$ty
{
impl
Repr
for
int
{
fn
write_repr
(
&
self
,
writer
:
@
Writer
)
{
do
::
int
::
to_str_bytes
(
*
self
,
10u
)
|
bits
|
{
writer
.write
(
bits
);
}
}
}
macro_rules!
int_repr
((
$ty:ident
,
$suffix:expr
)
=>
(
impl
Repr
for
$ty
{
fn
write_repr
(
&
self
,
writer
:
@
Writer
)
{
do
::
$ty
::
to_str_bytes
(
*
self
,
10u
)
|
bits
|
{
writer
.write
(
bits
);
writer
.write
(
bytes!
(
$suffix
));
}
}
}))
int_repr!
(
int
)
int_repr!
(
i8
)
int_repr!
(
i16
)
int_repr!
(
i32
)
int_repr!
(
i64
)
int_repr!
(
uint
)
int_repr!
(
u8
)
int_repr!
(
u16
)
int_repr!
(
u32
)
int_repr!
(
u64
)
macro_rules!
num_repr
((
$ty:ident
)
=>
(
impl
Repr
for
$ty
{
int_repr!
(
i8
,
"i8"
)
int_repr!
(
i16
,
"i16"
)
int_repr!
(
i32
,
"i32"
)
int_repr!
(
i64
,
"i64"
)
int_repr!
(
uint
,
"u"
)
int_repr!
(
u8
,
"u8"
)
int_repr!
(
u16
,
"u16"
)
int_repr!
(
u32
,
"u32"
)
int_repr!
(
u64
,
"u64"
)
impl
Repr
for
float
{
fn
write_repr
(
&
self
,
writer
:
@
Writer
)
{
let
s
=
self
.to_str
();
writer
.write
(
s
.as_bytes
());
}
}
macro_rules!
num_repr
((
$ty:ident
,
$suffix:expr
)
=>
(
impl
Repr
for
$ty
{
fn
write_repr
(
&
self
,
writer
:
@
Writer
)
{
let
s
=
self
.to_str
();
writer
.write
(
s
.as_bytes
());
writer
.write
(
bytes!
(
$suffix
));
}
}))
num_repr!
(
float
)
num_repr!
(
f32
)
num_repr!
(
f64
)
num_repr!
(
f32
,
"f32"
)
num_repr!
(
f64
,
"f64"
)
// New implementation using reflect::MovePtr
...
...
@@ -602,7 +617,7 @@ fn exact_test<T>(t: &T, e:&str) {
exact_test
(
&
(
@
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]),
"@[1, 2, 3, 4, 5, 6, 7, 8]"
);
exact_test
(
&
(
@
[
1u8
,
2u8
,
3u8
,
4u8
]),
"@[1
, 2, 3, 4
]"
);
"@[1
u8, 2u8, 3u8, 4u8
]"
);
exact_test
(
&
(
@
[
"hi"
,
"there"
]),
"@[
\"
hi
\"
,
\"
there
\"
]"
);
exact_test
(
&
(
~
[
"hi"
,
"there"
]),
...
...
@@ -615,14 +630,14 @@ fn exact_test<T>(t: &T, e:&str) {
"@{a: 10, b: 1.234}"
);
exact_test
(
&
(
~
P
{
a
:
10
,
b
:
1.234
}),
"~{a: 10, b: 1.234}"
);
exact_test
(
&
(
10
_
u8
,
~
"hello"
),
"(10, ~
\"
hello
\"
)"
);
exact_test
(
&
(
10
_
u16
,
~
"hello"
),
"(10, ~
\"
hello
\"
)"
);
exact_test
(
&
(
10
_
u32
,
~
"hello"
),
"(10, ~
\"
hello
\"
)"
);
exact_test
(
&
(
10
_
u64
,
~
"hello"
),
"(10, ~
\"
hello
\"
)"
);
exact_test
(
&
(
10u8
,
~
"hello"
),
"(10
u8
, ~
\"
hello
\"
)"
);
exact_test
(
&
(
10u16
,
~
"hello"
),
"(10
u16
, ~
\"
hello
\"
)"
);
exact_test
(
&
(
10u32
,
~
"hello"
),
"(10
u32
, ~
\"
hello
\"
)"
);
exact_test
(
&
(
10u64
,
~
"hello"
),
"(10
u64
, ~
\"
hello
\"
)"
);
struct
Foo
;
exact_test
(
&
(
~
[
Foo
,
Foo
,
Foo
]),
"~[{}, {}, {}]"
);
...
...
src/test/run-pass/fixed_length_vec_glue.rs
浏览文件 @
c2bc59e0
...
...
@@ -16,5 +16,5 @@ pub fn main() {
let
arr
=
[
1
,
2
,
3
];
let
struc
=
Struc
{
a
:
13u8
,
b
:
arr
,
c
:
42
};
let
s
=
sys
::
log_str
(
&
struc
);
assert_eq!
(
s
,
~
"{a: 13, b: [1, 2, 3], c: 42}"
);
assert_eq!
(
s
,
~
"{a: 13
u8
, b: [1, 2, 3], c: 42}"
);
}
src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
浏览文件 @
c2bc59e0
...
...
@@ -25,7 +25,7 @@ fn check_log<T>(exp: ~str, v: T) {
pub
fn
main
()
{
let
x
=
list
::
from_vec
([
a
(
22u
),
b
(
~
"hi"
)]);
let
exp
=
~
"@Cons(a(22), @Cons(b(~
\"
hi
\"
), @Nil))"
;
let
exp
=
~
"@Cons(a(22
u
), @Cons(b(~
\"
hi
\"
), @Nil))"
;
let
act
=
fmt!
(
"%?"
,
x
);
assert
!
(
act
==
exp
);
check_log
(
exp
,
x
);
...
...
src/test/run-pass/log-knows-the-names-of-variants.rs
浏览文件 @
c2bc59e0
...
...
@@ -19,7 +19,7 @@ enum bar {
}
pub
fn
main
()
{
assert_eq!
(
~
"a(22)"
,
fmt!
(
"%?"
,
a
(
22u
)));
assert_eq!
(
~
"a(22
u
)"
,
fmt!
(
"%?"
,
a
(
22u
)));
assert_eq!
(
~
"b(~
\"
hi
\"
)"
,
fmt!
(
"%?"
,
b
(
~
"hi"
)));
assert_eq!
(
~
"c"
,
fmt!
(
"%?"
,
c
));
assert_eq!
(
~
"d"
,
fmt!
(
"%?"
,
d
));
...
...
src/test/run-pass/rec-align-u32.rs
浏览文件 @
c2bc59e0
...
...
@@ -64,6 +64,6 @@ pub fn main() {
// because `inner`s alignment was 4.
assert_eq!
(
sys
::
size_of
::
<
Outer
>
(),
m
::
size
());
assert_eq!
(
y
,
~
"{c8: 22
, t: {c64: 44
}}"
);
assert_eq!
(
y
,
~
"{c8: 22
u8, t: {c64: 44u32
}}"
);
}
}
src/test/run-pass/rec-align-u64.rs
浏览文件 @
c2bc59e0
...
...
@@ -86,6 +86,6 @@ pub fn main() {
// because `Inner`s alignment was 4.
assert_eq!
(
sys
::
size_of
::
<
Outer
>
(),
m
::
m
::
size
());
assert_eq!
(
y
,
~
"{c8: 22
, t: {c64: 4
4}}"
);
assert_eq!
(
y
,
~
"{c8: 22
u8, t: {c64: 44u6
4}}"
);
}
}
src/test/run-pass/tag-align-shape.rs
浏览文件 @
c2bc59e0
...
...
@@ -21,5 +21,5 @@ pub fn main() {
let
x
=
t_rec
{
c8
:
22u8
,
t
:
a_tag
(
44u64
)};
let
y
=
fmt!
(
"%?"
,
x
);
info!
(
"y = %s"
,
y
);
assert_eq!
(
y
,
~
"{c8: 22
, t: a_tag(4
4)}"
);
assert_eq!
(
y
,
~
"{c8: 22
u8, t: a_tag(44u6
4)}"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录