gdritter repos rrecutils / f9e96f7
Add method to get type Getty Ritter 6 years ago
1 changed file(s) with 10 addition(s) and 0 deletion(s). Collapse all Expand all
4444 self.fields.len()
4545 }
4646
47 pub fn get_type<'a>(&'a self) -> Result<&'a str, RecError> {
48 match self.rec_type {
49 Some(ref t) => Ok(t),
50 None => Err(RecError::NoType),
51 }
52 }
53
4754 /// Return the value of the field named by the argument if it
4855 /// exists
4956 pub fn get<'a>(&'a self, name: &str) -> Result<&'a str, RecError> {
144151 MissingField {
145152 name: String,
146153 },
154
155 #[fail(display = "Missing type for record")]
156 NoType,
147157 }
148158
149159