Skip to content

Commit 9d401a6

Browse files
committed
build: cover parse() in tests::from_str_works
1 parent 71e502d commit 9d401a6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ impl AsRef<String> for NonEmptyString {
130130
}
131131
}
132132

133-
134133
impl<'s> TryFrom<&'s str> for NonEmptyString {
135134
type Error = &'s str;
136135

@@ -158,10 +157,10 @@ impl Display for NonEmptyString {
158157
}
159158

160159
impl FromStr for NonEmptyString {
161-
type Err= EmptyString;
160+
type Err = EmptyString;
162161

163162
fn from_str(s: &str) -> Result<Self, Self::Err> {
164-
if s.is_empty(){
163+
if s.is_empty() {
165164
return Err(EmptyString);
166165
}
167166

@@ -226,11 +225,11 @@ mod tests {
226225
let empty_str = "";
227226
let valid_str = "string";
228227

229-
let _non_empty_string = NonEmptyString::from_str(empty_str)
230-
.expect_err("operation must be failed");
228+
let _non_empty_string =
229+
NonEmptyString::from_str(empty_str).expect_err("operation must be failed");
231230

232231
let non_empty_string = NonEmptyString::from_str(valid_str).unwrap();
233232
assert_eq!(non_empty_string.as_str(), valid_str);
233+
assert_eq!(non_empty_string, valid_str.parse().unwrap());
234234
}
235-
236235
}

0 commit comments

Comments
 (0)