We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
cidr
FromSql
1 parentdd7bc07 commit27039f6Copy full SHA for 27039f6
postgres-types/src/cidr_02.rs
@@ -8,8 +8,7 @@ use crate::{FromSql, IsNull, ToSql, Type};
8
impl<'a>FromSql<'a>forIpCidr{
9
fnfrom_sql(_:&Type,raw:&[u8]) ->Result<Self,Box<dynError +Sync +Send>>{
10
let inet = types::inet_from_sql(raw)?;
11
-Ok(IpCidr::new(inet.addr(), inet.netmask())
12
-.expect("postgres cidr type has zeroed host portion"))
+Ok(IpCidr::new(inet.addr(), inet.netmask())?)
13
}
14
15
accepts!(CIDR);
@@ -28,8 +27,7 @@ impl ToSql for IpCidr {
28
27
impl<'a>FromSql<'a>forIpInet{
29
30
31
-Ok(IpInet::new(inet.addr(), inet.netmask())
32
-.expect("postgres enforces maximum length of netmask"))
+Ok(IpInet::new(inet.addr(), inet.netmask())?)
33
34
35
accepts!(INET);