aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/path.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-01-15 17:32:34 +0000
committerGitHub <[email protected]>2020-01-15 17:32:34 +0000
commit2f1df3cd74603bf1ba7f2e1c8833407a176cc66e (patch)
tree3fd74d1aa420b04f5c9e3aaf84ebb62e553ddb9c /crates/ra_hir_def/src/path.rs
parentc0661ce7444223b0fff1f5d54adb41022ab788cb (diff)
parent7d2d3ac3db6ea7bbb3d77569495176da3b2992e6 (diff)
Merge #2855
2855: More fluent API r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/path.rs')
-rw-r--r--crates/ra_hir_def/src/path.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs
index 9f93a5424..ab290e2c9 100644
--- a/crates/ra_hir_def/src/path.rs
+++ b/crates/ra_hir_def/src/path.rs
@@ -39,10 +39,7 @@ impl ModPath {
39 lower::lower_path(path, hygiene).map(|it| it.mod_path) 39 lower::lower_path(path, hygiene).map(|it| it.mod_path)
40 } 40 }
41 41
42 pub fn from_simple_segments( 42 pub fn from_segments(kind: PathKind, segments: impl IntoIterator<Item = Name>) -> ModPath {
43 kind: PathKind,
44 segments: impl IntoIterator<Item = Name>,
45 ) -> ModPath {
46 let segments = segments.into_iter().collect::<Vec<_>>(); 43 let segments = segments.into_iter().collect::<Vec<_>>();
47 ModPath { kind, segments } 44 ModPath { kind, segments }
48 } 45 }
@@ -240,7 +237,7 @@ impl From<Name> for Path {
240 fn from(name: Name) -> Path { 237 fn from(name: Name) -> Path {
241 Path { 238 Path {
242 type_anchor: None, 239 type_anchor: None,
243 mod_path: ModPath::from_simple_segments(PathKind::Plain, iter::once(name)), 240 mod_path: ModPath::from_segments(PathKind::Plain, iter::once(name)),
244 generic_args: vec![None], 241 generic_args: vec![None],
245 } 242 }
246 } 243 }
@@ -248,7 +245,7 @@ impl From<Name> for Path {
248 245
249impl From<Name> for ModPath { 246impl From<Name> for ModPath {
250 fn from(name: Name) -> ModPath { 247 fn from(name: Name) -> ModPath {
251 ModPath::from_simple_segments(PathKind::Plain, iter::once(name)) 248 ModPath::from_segments(PathKind::Plain, iter::once(name))
252 } 249 }
253} 250}
254 251
@@ -311,7 +308,7 @@ macro_rules! __known_path {
311macro_rules! __path { 308macro_rules! __path {
312 ($start:ident $(:: $seg:ident)*) => ({ 309 ($start:ident $(:: $seg:ident)*) => ({
313 $crate::__known_path!($start $(:: $seg)*); 310 $crate::__known_path!($start $(:: $seg)*);
314 $crate::path::ModPath::from_simple_segments($crate::path::PathKind::Abs, vec![ 311 $crate::path::ModPath::from_segments($crate::path::PathKind::Abs, vec![
315 $crate::path::__name![$start], $($crate::path::__name![$seg],)* 312 $crate::path::__name![$start], $($crate::path::__name![$seg],)*
316 ]) 313 ])
317 }); 314 });