aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/name.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/name.rs')
-rw-r--r--crates/ra_hir/src/name.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/crates/ra_hir/src/name.rs b/crates/ra_hir/src/name.rs
index e4fc141a6..51e8b3da8 100644
--- a/crates/ra_hir/src/name.rs
+++ b/crates/ra_hir/src/name.rs
@@ -23,6 +23,18 @@ impl fmt::Debug for Name {
23} 23}
24 24
25impl Name { 25impl Name {
26 fn new(text: SmolStr) -> Name {
27 Name { text }
28 }
29
30 pub(crate) fn missing() -> Name {
31 Name::new("[missing name]".into())
32 }
33
34 pub(crate) fn tuple_field_name(idx: usize) -> Name {
35 Name::new(idx.to_string().into())
36 }
37
26 pub(crate) fn as_known_name(&self) -> Option<KnownName> { 38 pub(crate) fn as_known_name(&self) -> Option<KnownName> {
27 let name = match self.text.as_str() { 39 let name = match self.text.as_str() {
28 "isize" => KnownName::Isize, 40 "isize" => KnownName::Isize,
@@ -43,10 +55,6 @@ impl Name {
43 }; 55 };
44 Some(name) 56 Some(name)
45 } 57 }
46
47 fn new(text: SmolStr) -> Name {
48 Name { text }
49 }
50} 58}
51 59
52pub(crate) trait AsName { 60pub(crate) trait AsName {