Skip to content

Commit 9a5f751

Browse files
committed
Merge pull request rust-postgres#97 from maurer/new-rustc
Update to new FromStr
2 parents 5fd3d70 + 6ac0b19 commit 9a5f751

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,10 @@ impl DbError {
533533
detail: map.remove(&b'D'),
534534
hint: map.remove(&b'H'),
535535
position: match map.remove(&b'P') {
536-
Some(pos) => Some(ErrorPosition::Normal(try!(pos.parse().ok_or(())))),
536+
Some(pos) => Some(ErrorPosition::Normal(try!(pos.parse().ok().ok_or(())))),
537537
None => match map.remove(&b'p') {
538538
Some(pos) => Some(ErrorPosition::Internal {
539-
position: try!(pos.parse().ok_or(())),
539+
position: try!(pos.parse().ok().ok_or(())),
540540
query: try!(map.remove(&b'q').ok_or(()))
541541
}),
542542
None => None
@@ -549,7 +549,7 @@ impl DbError {
549549
datatype: map.remove(&b'd'),
550550
constraint: map.remove(&b'n'),
551551
file: try!(map.remove(&b'F').ok_or(())),
552-
line: try!(map.remove(&b'L').and_then(|l| l.parse()).ok_or(())),
552+
line: try!(map.remove(&b'L').and_then(|l| l.parse().ok()).ok_or(())),
553553
routine: try!(map.remove(&b'R').ok_or(())),
554554
})
555555
}

src/url.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ fn get_authority(rawurl: &str) ->
371371
// If we have a port string, ensure it parses to u16.
372372
let port = match port {
373373
None => None,
374-
opt => match opt.and_then(|p| FromStr::from_str(p)) {
374+
opt => match opt.and_then(|p| FromStr::from_str(p).ok()) {
375375
None => return Err(format!("Failed to parse port: {:?}", port)),
376376
opt => opt
377377
}
@@ -428,14 +428,16 @@ fn get_query_fragment(rawurl: &str) -> DecodeResult<(Query, Option<String>)> {
428428
}
429429

430430
impl FromStr for Url {
431-
fn from_str(s: &str) -> Option<Url> {
432-
Url::parse(s).ok()
431+
type Err = String;
432+
fn from_str(s: &str) -> Result<Url, String> {
433+
Url::parse(s)
433434
}
434435
}
435436

436437
impl FromStr for Path {
437-
fn from_str(s: &str) -> Option<Path> {
438-
Path::parse(s).ok()
438+
type Err = String;
439+
fn from_str(s: &str) -> Result<Path, String> {
440+
Path::parse(s)
439441
}
440442
}
441443

0 commit comments

Comments
 (0)