-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON backend experimental impl #75114
Changes from 13 commits
ac408e4
3506135
8156b9a
c8b4e3c
ce4404a
5673bc5
ad67aea
e9af2d6
5ff33ca
d99ec1d
9ca0856
99d4784
a66a97a
338acee
47acf9a
cc85375
9147fd7
463e8b8
ec7a660
7ad40b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,6 +287,42 @@ pub enum ItemEnum { | |
} | ||
|
||
impl ItemEnum { | ||
/// Some items contain others such as structs (for their fields) and Enums | ||
/// (for their variants). This method returns those contained items. | ||
pub fn inner_items(&self) -> impl Iterator<Item = &Item> { | ||
match self { | ||
StructItem(s) => s.fields.iter(), | ||
UnionItem(u) => u.fields.iter(), | ||
VariantItem(Variant { kind: VariantKind::Struct(v) }) => v.fields.iter(), | ||
EnumItem(e) => e.variants.iter(), | ||
TraitItem(t) => t.items.iter(), | ||
ImplItem(i) => i.items.iter(), | ||
ModuleItem(m) => m.items.iter(), | ||
ExternCrateItem(_, _) | ||
| ImportItem(_) | ||
| FunctionItem(_) | ||
| TypedefItem(_, _) | ||
| OpaqueTyItem(_) | ||
| StaticItem(_) | ||
| ConstantItem(_) | ||
| TraitAliasItem(_) | ||
| TyMethodItem(_) | ||
| MethodItem(_) | ||
| StructFieldItem(_) | ||
| VariantItem(_) | ||
| ForeignFunctionItem(_) | ||
| ForeignStaticItem(_) | ||
| ForeignTypeItem | ||
| MacroItem(_) | ||
| ProcMacroItem(_) | ||
| PrimitiveItem(_) | ||
| AssocConstItem(_, _) | ||
| AssocTypeItem(_, _) | ||
| StrippedItem(_) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is correct? |
||
| KeywordItem(_) => [].iter(), | ||
} | ||
} | ||
|
||
pub fn is_type_alias(&self) -> bool { | ||
match *self { | ||
ItemEnum::TypedefItem(_, _) | ItemEnum::AssocTypeItem(_, _) => true, | ||
|
@@ -1576,6 +1612,11 @@ impl Path { | |
pub fn last_name(&self) -> &str { | ||
self.segments.last().expect("segments were empty").name.as_str() | ||
} | ||
|
||
pub fn whole_name(&self) -> String { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this contextually dependent? What's the difference towards a fully qualified path? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't be contextually dependent, it is just the fully qualified path. |
||
String::from(if self.global { "::" } else { "" }) | ||
+ &self.segments.iter().map(|s| s.name.clone()).collect::<Vec<_>>().join("::") | ||
} | ||
} | ||
|
||
#[derive(Clone, PartialEq, Eq, Debug, Hash)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?