aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/primitive.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/primitive.rs b/crates/ra_hir/src/ty/primitive.rs
index 4a5ce5a97..ad79b17e4 100644
--- a/crates/ra_hir/src/ty/primitive.rs
+++ b/crates/ra_hir/src/ty/primitive.rs
@@ -33,6 +33,18 @@ impl IntTy {
33 IntTy::I128 => "i128", 33 IntTy::I128 => "i128",
34 } 34 }
35 } 35 }
36
37 pub fn from_string(s: &str) -> Option<IntTy> {
38 match s {
39 "isize" => Some(IntTy::Isize),
40 "i8" => Some(IntTy::I8),
41 "i16" => Some(IntTy::I16),
42 "i32" => Some(IntTy::I32),
43 "i64" => Some(IntTy::I64),
44 "i128" => Some(IntTy::I128),
45 _ => None,
46 }
47 }
36} 48}
37 49
38#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)] 50#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
@@ -56,6 +68,18 @@ impl UintTy {
56 UintTy::U128 => "u128", 68 UintTy::U128 => "u128",
57 } 69 }
58 } 70 }
71
72 pub fn from_string(s: &str) -> Option<UintTy> {
73 match s {
74 "usize" => Some(UintTy::Usize),
75 "u8" => Some(UintTy::U8),
76 "u16" => Some(UintTy::U16),
77 "u32" => Some(UintTy::U32),
78 "u64" => Some(UintTy::U64),
79 "u128" => Some(UintTy::U128),
80 _ => None,
81 }
82 }
59} 83}
60 84
61impl fmt::Debug for UintTy { 85impl fmt::Debug for UintTy {
@@ -95,4 +119,12 @@ impl FloatTy {
95 FloatTy::F64 => "f64", 119 FloatTy::F64 => "f64",
96 } 120 }
97 } 121 }
122
123 pub fn from_string(s: &str) -> Option<FloatTy> {
124 match s {
125 "f32" => Some(FloatTy::F32),
126 "f64" => Some(FloatTy::F64),
127 _ => None,
128 }
129 }
98} 130}