radicle/tor: Fixes
Fixes two earlier mistakes:
1. In `fb18083`, `fn null_to_default` was added, which is only
conditionally used if the feature "tor" is enabled, so also
only conditionally compile the function.
2. In `1e13268`, the `impl Arbitrary` for AddressType` was not
properly adjusted for the case where the newly introduced
feature "tor" is disabled.
This commit is contained in:
parent
f223afd9d7
commit
b54fc820e9
|
|
@ -47,6 +47,7 @@ where
|
|||
}
|
||||
|
||||
/// Deserialize a value, but if it is `null`, return the default value.
|
||||
#[cfg(feature = "tor")]
|
||||
pub(crate) fn null_to_default<'de, D, T>(deserializer: D) -> Result<T, D::Error>
|
||||
where
|
||||
T: serde::Deserialize<'de> + Default,
|
||||
|
|
|
|||
|
|
@ -208,7 +208,12 @@ impl Arbitrary for MockRepository {
|
|||
|
||||
impl Arbitrary for AddressType {
|
||||
fn arbitrary(g: &mut qcheck::Gen) -> Self {
|
||||
let t = *g.choose(&[1, 2, 3, 4]).unwrap() as u8;
|
||||
#[cfg(not(feature = "tor"))]
|
||||
let types = [1, 2, 3];
|
||||
#[cfg(feature = "tor")]
|
||||
let types = [1, 2, 3, 4];
|
||||
|
||||
let t = *g.choose(&types).unwrap() as u8;
|
||||
|
||||
AddressType::try_from(t).unwrap()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue