Skip to content

Commit 30397ae

Browse files
committed
Migrate ItemType::from_item to convert::From.
1 parent 7dc4116 commit 30397ae

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,34 +287,34 @@ impl Item {
287287
}
288288
}
289289
pub fn is_mod(&self) -> bool {
290-
ItemType::from_item(self) == ItemType::Module
290+
ItemType::from(self) == ItemType::Module
291291
}
292292
pub fn is_trait(&self) -> bool {
293-
ItemType::from_item(self) == ItemType::Trait
293+
ItemType::from(self) == ItemType::Trait
294294
}
295295
pub fn is_struct(&self) -> bool {
296-
ItemType::from_item(self) == ItemType::Struct
296+
ItemType::from(self) == ItemType::Struct
297297
}
298298
pub fn is_enum(&self) -> bool {
299-
ItemType::from_item(self) == ItemType::Module
299+
ItemType::from(self) == ItemType::Module
300300
}
301301
pub fn is_fn(&self) -> bool {
302-
ItemType::from_item(self) == ItemType::Function
302+
ItemType::from(self) == ItemType::Function
303303
}
304304
pub fn is_associated_type(&self) -> bool {
305-
ItemType::from_item(self) == ItemType::AssociatedType
305+
ItemType::from(self) == ItemType::AssociatedType
306306
}
307307
pub fn is_associated_const(&self) -> bool {
308-
ItemType::from_item(self) == ItemType::AssociatedConst
308+
ItemType::from(self) == ItemType::AssociatedConst
309309
}
310310
pub fn is_method(&self) -> bool {
311-
ItemType::from_item(self) == ItemType::Method
311+
ItemType::from(self) == ItemType::Method
312312
}
313313
pub fn is_ty_method(&self) -> bool {
314-
ItemType::from_item(self) == ItemType::TyMethod
314+
ItemType::from(self) == ItemType::TyMethod
315315
}
316316
pub fn is_primitive(&self) -> bool {
317-
ItemType::from_item(self) == ItemType::Primitive
317+
ItemType::from(self) == ItemType::Primitive
318318
}
319319
pub fn is_stripped(&self) -> bool {
320320
match self.inner { StrippedItem(..) => true, _ => false }

src/librustdoc/html/item_type.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ pub enum NameSpace {
5050
Macro,
5151
}
5252

53-
impl ItemType {
54-
pub fn from_item(item: &clean::Item) -> ItemType {
53+
impl<'a> From<&'a clean::Item> for ItemType {
54+
fn from(item: &'a clean::Item) -> ItemType {
5555
let inner = match item.inner {
5656
clean::StrippedItem(box ref item) => item,
5757
ref inner@_ => inner,
@@ -83,7 +83,9 @@ impl ItemType {
8383
clean::StrippedItem(..) => unreachable!(),
8484
}
8585
}
86+
}
8687

88+
impl ItemType {
8789
pub fn from_type_kind(kind: clean::TypeKind) -> ItemType {
8890
match kind {
8991
clean::TypeStruct => ItemType::Struct,

src/librustdoc/html/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ fn mkdir(path: &Path) -> io::Result<()> {
833833

834834
/// Returns a documentation-level item type from the item.
835835
fn item_type(item: &clean::Item) -> ItemType {
836-
ItemType::from_item(item)
836+
ItemType::from(item)
837837
}
838838

839839
/// Takes a path to a source file and cleans the path to it. This canonicalizes

0 commit comments

Comments
 (0)