Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a7b311ac
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,发现更多精彩内容 >>
提交
a7b311ac
编写于
11月 29, 2013
作者:
E
Erick Tryzelaar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
extra: missed a couple `@` in json
上级
6818b96a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
15 deletion
+19
-15
src/libextra/json.rs
src/libextra/json.rs
+9
-9
src/libextra/test.rs
src/libextra/test.rs
+3
-2
src/librustdoc/lib.rs
src/librustdoc/lib.rs
+6
-3
src/libsyntax/parse/mod.rs
src/libsyntax/parse/mod.rs
+1
-1
未找到文件。
src/libextra/json.rs
浏览文件 @
a7b311ac
...
...
@@ -464,7 +464,7 @@ pub fn to_pretty_writer(&self, wr: &mut io::Writer) {
pub
fn
to_pretty_str
(
&
self
)
->
~
str
{
let
mut
s
=
MemWriter
::
new
();
self
.to_pretty_writer
(
&
mut
s
as
&
mut
io
::
Writer
);
str
::
from_utf8
(
s
.inner_ref
()
.as_slice
())
str
::
from_utf8
_owned
(
s
.inner
())
}
}
...
...
@@ -847,7 +847,7 @@ fn parse_object(&mut self) -> Result<Json, Error> {
/// Decodes a json value from an `&mut io::Reader`
pub
fn
from_reader
(
rdr
:
&
mut
io
::
Reader
)
->
Result
<
Json
,
Error
>
{
let
s
=
str
::
from_utf8
(
rdr
.read_to_end
());
let
s
=
str
::
from_utf8
_owned
(
rdr
.read_to_end
());
let
mut
parser
=
Parser
::
init
(
s
.chars
());
parser
.parse
()
}
...
...
@@ -1319,9 +1319,9 @@ fn to_json(&self) -> Json {
impl
to_str
::
ToStr
for
Json
{
/// Encodes a json value into a string
fn
to_str
(
&
self
)
->
~
str
{
let
s
=
@
mut
MemWriter
::
new
();
self
.to_writer
(
s
as
@
mut
io
::
Writer
);
str
::
from_utf8
(
s
.inner_ref
()
.as_slice
())
let
mut
s
=
MemWriter
::
new
();
self
.to_writer
(
&
mut
s
as
&
mut
io
::
Writer
);
str
::
from_utf8
_owned
(
s
.inner
())
}
}
...
...
@@ -1507,14 +1507,14 @@ fn test_write_object() {
assert_eq!
(
a
.clone
(),
from_str
(
a
.to_pretty_str
())
.unwrap
());
}
fn
with_str_writer
(
f
:
|
@
mut
io
::
Writer
|)
->
~
str
{
fn
with_str_writer
(
f
:
|
&
mut
io
::
Writer
|)
->
~
str
{
use
std
::
io
::
mem
::
MemWriter
;
use
std
::
io
::
Decorator
;
use
std
::
str
;
let
m
=
@
mut
MemWriter
::
new
();
f
(
m
as
@
mut
io
::
Writer
);
str
::
from_utf8
(
*
m
.inner_ref
())
let
m
ut
m
=
MemWriter
::
new
();
f
(
&
mut
m
as
&
mut
io
::
Writer
);
str
::
from_utf8
_owned
(
m
.inner
())
}
#[test]
...
...
src/libextra/test.rs
浏览文件 @
a7b311ac
...
...
@@ -945,8 +945,9 @@ pub fn new() -> MetricMap {
/// Load MetricDiff from a file.
pub
fn
load
(
p
:
&
Path
)
->
MetricMap
{
assert
!
(
p
.exists
());
let
f
=
@
mut
File
::
open
(
p
)
as
@
mut
io
::
Reader
;
let
mut
decoder
=
json
::
Decoder
::
init
(
json
::
from_reader
(
f
)
.unwrap
());
let
mut
f
=
File
::
open
(
p
);
let
value
=
json
::
from_reader
(
&
mut
f
as
&
mut
io
::
Reader
)
.unwrap
();
let
mut
decoder
=
json
::
Decoder
::
init
(
value
);
MetricMap
(
Decodable
::
decode
(
&
mut
decoder
))
}
...
...
src/librustdoc/lib.rs
浏览文件 @
a7b311ac
...
...
@@ -312,9 +312,12 @@ fn json_output(crate: clean::Crate, res: ~[plugins::PluginJson], dst: Path) {
// FIXME #8335: yuck, Rust -> str -> JSON round trip! No way to .encode
// straight to the Rust JSON representation.
let
crate_json_str
=
{
let
w
=
@
mut
MemWriter
::
new
();
crate
.encode
(
&
mut
json
::
Encoder
::
init
(
w
as
@
mut
io
::
Writer
));
str
::
from_utf8
(
*
w
.inner_ref
())
let
mut
w
=
MemWriter
::
new
();
{
let
mut
encoder
=
json
::
Encoder
::
init
(
&
mut
w
as
&
mut
io
::
Writer
);
crate
.encode
(
&
mut
encoder
);
}
str
::
from_utf8_owned
(
w
.inner
())
};
let
crate_json
=
match
json
::
from_str
(
crate_json_str
)
{
Ok
(
j
)
=>
j
,
...
...
src/libsyntax/parse/mod.rs
浏览文件 @
a7b311ac
...
...
@@ -346,7 +346,7 @@ fn to_json_str<'a, E: Encodable<extra::json::Encoder<'a>>>(val: &E) -> ~str {
let
mut
writer
=
MemWriter
::
new
();
let
mut
encoder
=
extra
::
json
::
Encoder
::
init
(
&
mut
writer
as
&
mut
io
::
Writer
);
val
.encode
(
&
mut
encoder
);
str
::
from_utf8
(
*
writer
.inner_ref
())
str
::
from_utf8
_owned
(
writer
.inner
())
}
// produce a codemap::span
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录