Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
03215621
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,发现更多精彩内容 >>
提交
03215621
编写于
2月 28, 2016
作者:
M
mitaa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use `Item::is_*` methods consistently
上级
2a28b699
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
22 deletion
+26
-22
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+20
-4
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+6
-18
未找到文件。
src/librustdoc/clean/mod.rs
浏览文件 @
03215621
...
...
@@ -175,9 +175,8 @@ fn clean(&self, cx: &DocContext) -> Crate {
};
let
mut
tmp
=
Vec
::
new
();
for
child
in
&
mut
m
.items
{
match
child
.inner
{
ModuleItem
(
..
)
=>
{}
_
=>
continue
,
if
!
child
.is_mod
()
{
continue
;
}
let
prim
=
match
PrimitiveType
::
find
(
&
child
.attrs
)
{
Some
(
prim
)
=>
prim
,
...
...
@@ -272,7 +271,12 @@ impl Item {
pub
fn
doc_value
<
'a
>
(
&
'a
self
)
->
Option
<&
'a
str
>
{
self
.attrs
.value
(
"doc"
)
}
pub
fn
is_crate
(
&
self
)
->
bool
{
match
self
.inner
{
ModuleItem
(
Module
{
items
:
_
,
is_crate
:
true
})
=>
true
,
_
=>
false
}
}
pub
fn
is_mod
(
&
self
)
->
bool
{
match
self
.inner
{
ModuleItem
(
..
)
=>
true
,
_
=>
false
}
}
...
...
@@ -288,6 +292,18 @@ pub fn is_enum(&self) -> bool {
pub
fn
is_fn
(
&
self
)
->
bool
{
match
self
.inner
{
FunctionItem
(
..
)
=>
true
,
_
=>
false
}
}
pub
fn
is_associated_type
(
&
self
)
->
bool
{
match
self
.inner
{
AssociatedTypeItem
(
..
)
=>
true
,
_
=>
false
}
}
pub
fn
is_associated_const
(
&
self
)
->
bool
{
match
self
.inner
{
AssociatedConstItem
(
..
)
=>
true
,
_
=>
false
}
}
pub
fn
is_method
(
&
self
)
->
bool
{
match
self
.inner
{
MethodItem
(
..
)
=>
true
,
_
=>
false
}
}
pub
fn
is_ty_method
(
&
self
)
->
bool
{
match
self
.inner
{
TyMethodItem
(
..
)
=>
true
,
_
=>
false
}
}
pub
fn
stability_class
(
&
self
)
->
String
{
self
.stability
.as_ref
()
.map
(|
ref
s
|
{
...
...
src/librustdoc/html/render.rs
浏览文件 @
03215621
...
...
@@ -1266,11 +1266,7 @@ fn render(w: File, cx: &Context, it: &clean::Item,
}
title
.push_str
(
" - Rust"
);
let
tyname
=
shortty
(
it
)
.to_static_str
();
let
is_crate
=
match
it
.inner
{
clean
::
ModuleItem
(
clean
::
Module
{
items
:
_
,
is_crate
:
true
})
=>
true
,
_
=>
false
};
let
desc
=
if
is_crate
{
let
desc
=
if
it
.is_crate
()
{
format!
(
"API documentation for the Rust `{}` crate."
,
cx
.layout.krate
)
}
else
{
...
...
@@ -1891,18 +1887,10 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
bounds
,
WhereClause
(
&
t
.generics
)));
let
types
=
t
.items
.iter
()
.filter
(|
m
|
{
match
m
.inner
{
clean
::
AssociatedTypeItem
(
..
)
=>
true
,
_
=>
false
}
})
.collect
::
<
Vec
<
_
>>
();
let
consts
=
t
.items
.iter
()
.filter
(|
m
|
{
match
m
.inner
{
clean
::
AssociatedConstItem
(
..
)
=>
true
,
_
=>
false
}
})
.collect
::
<
Vec
<
_
>>
();
let
required
=
t
.items
.iter
()
.filter
(|
m
|
{
match
m
.inner
{
clean
::
TyMethodItem
(
_
)
=>
true
,
_
=>
false
}
})
.collect
::
<
Vec
<
_
>>
();
let
provided
=
t
.items
.iter
()
.filter
(|
m
|
{
match
m
.inner
{
clean
::
MethodItem
(
_
)
=>
true
,
_
=>
false
}
})
.collect
::
<
Vec
<
_
>>
();
let
types
=
t
.items
.iter
()
.filter
(|
m
|
m
.is_associated_type
())
.collect
::
<
Vec
<
_
>>
();
let
consts
=
t
.items
.iter
()
.filter
(|
m
|
m
.is_associated_const
())
.collect
::
<
Vec
<
_
>>
();
let
required
=
t
.items
.iter
()
.filter
(|
m
|
m
.is_ty_method
())
.collect
::
<
Vec
<
_
>>
();
let
provided
=
t
.items
.iter
()
.filter
(|
m
|
m
.is_method
())
.collect
::
<
Vec
<
_
>>
();
if
t
.items
.is_empty
()
{
try!
(
write!
(
w
,
"{{ }}"
));
...
...
@@ -2600,7 +2588,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!
(
write!
(
fmt
,
"</p>"
));
// sidebar refers to the enclosing module, not this module
let
relpath
=
if
shortty
(
it
)
==
ItemType
::
Module
{
"../"
}
else
{
""
};
let
relpath
=
if
it
.is_mod
()
{
"../"
}
else
{
""
};
try!
(
write!
(
fmt
,
"<script>window.sidebarCurrent = {{
\
name: '{name}',
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录