diff options
Diffstat (limited to 'crates/ra_db/src/input.rs')
-rw-r--r-- | crates/ra_db/src/input.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 60f7dc881..fb9a3297a 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -13,6 +13,7 @@ use ra_syntax::SmolStr; | |||
13 | use rustc_hash::FxHashSet; | 13 | use rustc_hash::FxHashSet; |
14 | 14 | ||
15 | use crate::{RelativePath, RelativePathBuf}; | 15 | use crate::{RelativePath, RelativePathBuf}; |
16 | use std::str::FromStr; | ||
16 | 17 | ||
17 | /// `FileId` is an integer which uniquely identifies a file. File paths are | 18 | /// `FileId` is an integer which uniquely identifies a file. File paths are |
18 | /// messy and system-dependent, so most of the code should work directly with | 19 | /// messy and system-dependent, so most of the code should work directly with |
@@ -97,12 +98,13 @@ pub enum Edition { | |||
97 | Edition2015, | 98 | Edition2015, |
98 | } | 99 | } |
99 | 100 | ||
100 | impl Edition { | 101 | impl FromStr for Edition { |
101 | //FIXME: replace with FromStr with proper error handling | 102 | type Err = String; |
102 | pub fn from_string(s: &str) -> Edition { | 103 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
103 | match s { | 104 | match s { |
104 | "2015" => Edition::Edition2015, | 105 | "2015" => Ok(Edition::Edition2015), |
105 | "2018" | _ => Edition::Edition2018, | 106 | "2018" => Ok(Edition::Edition2018), |
107 | _ => Err(format! {"unknown edition: {}" , s}), | ||
106 | } | 108 | } |
107 | } | 109 | } |
108 | } | 110 | } |