From f21f4b4733358292cacedb405429e9425a8a73dd Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sat, 14 Dec 2019 16:00:11 +0100 Subject: [PATCH] Replace `.err().unwrap()` with `.unwrap_err()` --- src/event_id.rs | 16 +++++----------- src/room_alias_id.rs | 12 ++++-------- src/room_id.rs | 10 ++++------ src/room_id_or_room_alias_id.rs | 2 +- src/user_id.rs | 15 +++++---------- 5 files changed, 19 insertions(+), 36 deletions(-) diff --git a/src/event_id.rs b/src/event_id.rs index f70cd50c..1b39685c 100644 --- a/src/event_id.rs +++ b/src/event_id.rs @@ -324,7 +324,7 @@ mod tests { #[test] fn missing_original_event_id_sigil() { assert_eq!( - EventId::try_from("39hvsi03hlne:example.com").err().unwrap(), + EventId::try_from("39hvsi03hlne:example.com").unwrap_err(), Error::MissingSigil ); } @@ -332,9 +332,7 @@ mod tests { #[test] fn missing_base64_event_id_sigil() { assert_eq!( - EventId::try_from("acR1l0raoZnm60CBwAVgqbZqoO/mYU81xysh1u7XcJk") - .err() - .unwrap(), + EventId::try_from("acR1l0raoZnm60CBwAVgqbZqoO/mYU81xysh1u7XcJk").unwrap_err(), Error::MissingSigil ); } @@ -342,9 +340,7 @@ mod tests { #[test] fn missing_url_safe_base64_event_id_sigil() { assert_eq!( - EventId::try_from("Rqnc-F-dvnEYJTyHq_iKxU2bZ1CI92-kuZq3a5lr5Zg") - .err() - .unwrap(), + EventId::try_from("Rqnc-F-dvnEYJTyHq_iKxU2bZ1CI92-kuZq3a5lr5Zg").unwrap_err(), Error::MissingSigil ); } @@ -352,7 +348,7 @@ mod tests { #[test] fn invalid_event_id_host() { assert_eq!( - EventId::try_from("$39hvsi03hlne:/").err().unwrap(), + EventId::try_from("$39hvsi03hlne:/").unwrap_err(), Error::InvalidHost ); } @@ -360,9 +356,7 @@ mod tests { #[test] fn invalid_event_id_port() { assert_eq!( - EventId::try_from("$39hvsi03hlne:example.com:notaport") - .err() - .unwrap(), + EventId::try_from("$39hvsi03hlne:example.com:notaport").unwrap_err(), Error::InvalidHost ); } diff --git a/src/room_alias_id.rs b/src/room_alias_id.rs index 0883f293..418b0878 100644 --- a/src/room_alias_id.rs +++ b/src/room_alias_id.rs @@ -171,9 +171,7 @@ mod tests { #[test] fn missing_room_alias_id_sigil() { assert_eq!( - RoomAliasId::try_from("39hvsi03hlne:example.com") - .err() - .unwrap(), + RoomAliasId::try_from("39hvsi03hlne:example.com").unwrap_err(), Error::MissingSigil ); } @@ -181,7 +179,7 @@ mod tests { #[test] fn missing_room_alias_id_delimiter() { assert_eq!( - RoomAliasId::try_from("#ruma").err().unwrap(), + RoomAliasId::try_from("#ruma").unwrap_err(), Error::MissingDelimiter ); } @@ -189,7 +187,7 @@ mod tests { #[test] fn invalid_room_alias_id_host() { assert_eq!( - RoomAliasId::try_from("#ruma:/").err().unwrap(), + RoomAliasId::try_from("#ruma:/").unwrap_err(), Error::InvalidHost ); } @@ -197,9 +195,7 @@ mod tests { #[test] fn invalid_room_alias_id_port() { assert_eq!( - RoomAliasId::try_from("#ruma:example.com:notaport") - .err() - .unwrap(), + RoomAliasId::try_from("#ruma:example.com:notaport").unwrap_err(), Error::InvalidHost ); } diff --git a/src/room_id.rs b/src/room_id.rs index 8c17bfb7..2ffc61bb 100644 --- a/src/room_id.rs +++ b/src/room_id.rs @@ -191,7 +191,7 @@ mod tests { #[test] fn missing_room_id_sigil() { assert_eq!( - RoomId::try_from("carl:example.com").err().unwrap(), + RoomId::try_from("carl:example.com").unwrap_err(), Error::MissingSigil ); } @@ -199,7 +199,7 @@ mod tests { #[test] fn missing_room_id_delimiter() { assert_eq!( - RoomId::try_from("!29fhd83h92h0").err().unwrap(), + RoomId::try_from("!29fhd83h92h0").unwrap_err(), Error::MissingDelimiter ); } @@ -207,7 +207,7 @@ mod tests { #[test] fn invalid_room_id_host() { assert_eq!( - RoomId::try_from("!29fhd83h92h0:/").err().unwrap(), + RoomId::try_from("!29fhd83h92h0:/").unwrap_err(), Error::InvalidHost ); } @@ -215,9 +215,7 @@ mod tests { #[test] fn invalid_room_id_port() { assert_eq!( - RoomId::try_from("!29fhd83h92h0:example.com:notaport") - .err() - .unwrap(), + RoomId::try_from("!29fhd83h92h0:example.com:notaport").unwrap_err(), Error::InvalidHost ); } diff --git a/src/room_id_or_room_alias_id.rs b/src/room_id_or_room_alias_id.rs index 687cf3e1..cc20b18e 100644 --- a/src/room_id_or_room_alias_id.rs +++ b/src/room_id_or_room_alias_id.rs @@ -150,7 +150,7 @@ mod tests { #[test] fn missing_sigil_for_room_id_or_alias_id() { assert_eq!( - RoomIdOrAliasId::try_from("ruma:example.com").err().unwrap(), + RoomIdOrAliasId::try_from("ruma:example.com").unwrap_err(), Error::MissingSigil ); } diff --git a/src/user_id.rs b/src/user_id.rs index 4e31a9ca..f01c03bc 100644 --- a/src/user_id.rs +++ b/src/user_id.rs @@ -236,7 +236,7 @@ mod tests { #[test] fn invalid_characters_in_user_id_localpart() { assert_eq!( - UserId::try_from("@te\nst:example.com").err().unwrap(), + UserId::try_from("@te\nst:example.com").unwrap_err(), Error::InvalidCharacters ); } @@ -244,7 +244,7 @@ mod tests { #[test] fn missing_user_id_sigil() { assert_eq!( - UserId::try_from("carl:example.com").err().unwrap(), + UserId::try_from("carl:example.com").unwrap_err(), Error::MissingSigil ); } @@ -252,25 +252,20 @@ mod tests { #[test] fn missing_user_id_delimiter() { assert_eq!( - UserId::try_from("@carl").err().unwrap(), + UserId::try_from("@carl").unwrap_err(), Error::MissingDelimiter ); } #[test] fn invalid_user_id_host() { - assert_eq!( - UserId::try_from("@carl:/").err().unwrap(), - Error::InvalidHost - ); + assert_eq!(UserId::try_from("@carl:/").unwrap_err(), Error::InvalidHost); } #[test] fn invalid_user_id_port() { assert_eq!( - UserId::try_from("@carl:example.com:notaport") - .err() - .unwrap(), + UserId::try_from("@carl:example.com:notaport").unwrap_err(), Error::InvalidHost ); }