diff --git a/kanidm_tools/src/cli/lib.rs b/kanidm_tools/src/cli/lib.rs index 35c9ba9a7..681d20ba8 100644 --- a/kanidm_tools/src/cli/lib.rs +++ b/kanidm_tools/src/cli/lib.rs @@ -3,12 +3,13 @@ #![deny(clippy::todo)] #![deny(clippy::unimplemented)] #![deny(clippy::unwrap_used)] -#![deny(clippy::expect_used)] #![deny(clippy::panic)] #![deny(clippy::unreachable)] #![deny(clippy::await_holding_lock)] #![deny(clippy::needless_pass_by_value)] #![deny(clippy::trivially_copy_pass_by_ref)] +// We allow expect since it forces good error messages at the least. +#![allow(clippy::expect_used)] #[macro_use] extern crate tracing; diff --git a/kanidm_tools/src/cli/main.rs b/kanidm_tools/src/cli/main.rs index 399711a76..5c2c8fbc2 100644 --- a/kanidm_tools/src/cli/main.rs +++ b/kanidm_tools/src/cli/main.rs @@ -3,12 +3,13 @@ #![deny(clippy::todo)] #![deny(clippy::unimplemented)] #![deny(clippy::unwrap_used)] -#![deny(clippy::expect_used)] #![deny(clippy::panic)] #![deny(clippy::unreachable)] #![deny(clippy::await_holding_lock)] #![deny(clippy::needless_pass_by_value)] #![deny(clippy::trivially_copy_pass_by_ref)] +// We allow expect since it forces good error messages at the least. +#![allow(clippy::expect_used)] use clap::Parser; use kanidm_cli::KanidmClientParser; diff --git a/kanidm_tools/src/cli/person.rs b/kanidm_tools/src/cli/person.rs index 8f2c8323d..28da66ce9 100644 --- a/kanidm_tools/src/cli/person.rs +++ b/kanidm_tools/src/cli/person.rs @@ -478,8 +478,7 @@ impl AccountCredential { ClientErrorHttp(status_code, error, _kopid) => { eprintln!( "Error completing command: HTTP{} - {:?}", - status_code, - error.unwrap() + status_code, error ); } _ => error!("Error starting use_reset_token -> {:?}", e), @@ -496,7 +495,13 @@ impl AccountCredential { .await { Ok(cuintent_token) => { - let mut url = Url::parse(client.get_url()).expect("Invalid server url."); + let mut url = match Url::parse(client.get_url()) { + Ok(u) => u, + Err(e) => { + error!("Unable to parse url - {:?}", e); + return; + } + }; url.set_path("/ui/reset"); url.query_pairs_mut() .append_pair("token", cuintent_token.token.as_str()); @@ -666,7 +671,7 @@ async fn totp_enroll_prompt(session_token: &CUSessionToken, client: &KanidmClien } }) .interact_text() - .unwrap(); + .expect("Failed to interact with interactive session"); // cancel, submit the reg cancel. let totp_chal = match input.trim().parse::() { @@ -722,7 +727,7 @@ async fn totp_enroll_prompt(session_token: &CUSessionToken, client: &KanidmClien .items(&items) .default(0) .interact() - .unwrap(); + .expect("Failed to interact with interactive session"); match selection { 1 => { @@ -801,7 +806,7 @@ async fn passkey_enroll_prompt(session_token: &CUSessionToken, client: &KanidmCl .with_prompt("\nEnter a label for this Passkey # ") .allow_empty(false) .interact_text() - .unwrap(); + .expect("Failed to interact with interactive session"); match client .idm_account_credential_update_passkey_finish(session_token, label, rego) @@ -814,56 +819,6 @@ async fn passkey_enroll_prompt(session_token: &CUSessionToken, client: &KanidmCl }; } -// For webauthn later - -/* - AccountCredential::RegisterWebauthn(acsopt) => { - let client = acsopt.copt.to_client().await; - - let (session, chal) = match client - .idm_account_primary_credential_register_webauthn( - acsopt.aopts.account_id.as_str(), - acsopt.tag.as_str(), - ) - .await - { - Ok(v) => v, - Err(e) => { - error!("Error Starting Registration -> {:?}", e); - return; - } - }; - - let mut wa = WebauthnAuthenticator::new(U2FHid::new()); - - eprintln!("Your authenticator will now flash for you to interact with."); - - let rego = match wa.do_registration(client.get_origin(), chal) { - Ok(rego) => rego, - Err(e) => { - error!("Error Signing -> {:?}", e); - return; - } - }; - - match client - .idm_account_primary_credential_complete_webuthn_registration( - acsopt.aopts.account_id.as_str(), - rego, - session, - ) - .await - { - Ok(()) => { - println!("Webauthn token registration success."); - } - Err(e) => { - error!("Error Completing -> {:?}", e); - } - } - } -*/ - fn display_status(status: CUStatus) { let CUStatus { spn, @@ -921,7 +876,7 @@ async fn credential_update_exec( } }) .interact_text() - .unwrap(); + .expect("Failed to interact with interactive session"); // Get action let action = match CUAction::from_str(&input) { @@ -950,11 +905,11 @@ async fn credential_update_exec( let password_a = Password::new() .with_prompt("New password") .interact() - .unwrap(); + .expect("Failed to interact with interactive session"); let password_b = Password::new() .with_prompt("Confirm password") .interact() - .unwrap(); + .expect("Failed to interact with interactive session"); if password_a != password_b { eprintln!("Passwords do not match"); @@ -980,7 +935,7 @@ async fn credential_update_exec( if Confirm::new() .with_prompt("Do you want to remove your totp?") .interact() - .unwrap() + .expect("Failed to interact with interactive session") { if let Err(e) = client .idm_account_credential_update_remove_totp(&session_token) @@ -1022,7 +977,7 @@ async fn credential_update_exec( if Confirm::new() .with_prompt("Do you want to remove your primary credential?") .interact() - .unwrap() + .expect("Failed to interact with interactive session") { if let Err(e) = client .idm_account_credential_update_primary_remove(&session_token) @@ -1068,7 +1023,7 @@ async fn credential_update_exec( }) .allow_empty(true) .interact_text() - .unwrap(); + .expect("Failed to interact with interactive session"); // Remeber, if it's NOT a valid uuid, it must have been empty as a termination. if let Ok(uuid) = Uuid::parse_str(&uuid_s) { @@ -1092,7 +1047,7 @@ async fn credential_update_exec( if Confirm::new() .with_prompt("Do you want to commit your changes?") .interact() - .unwrap() + .expect("Failed to interact with interactive session") { if let Err(e) = client .idm_account_credential_update_commit(&session_token) diff --git a/kanidm_tools/src/ssh_authorizedkeys.rs b/kanidm_tools/src/ssh_authorizedkeys.rs index 64cde089c..48e260507 100644 --- a/kanidm_tools/src/ssh_authorizedkeys.rs +++ b/kanidm_tools/src/ssh_authorizedkeys.rs @@ -47,7 +47,7 @@ async fn main() { None => client_builder, }; - let ca_path = opt.ca_path.as_ref().map(|p| p.to_str()).flatten(); + let ca_path = opt.ca_path.as_ref().and_then(|p| p.to_str()); let client_builder = match ca_path { Some(p) => client_builder .add_root_certificate_filepath(p) diff --git a/kanidmd/idm/src/access.rs b/kanidmd/idm/src/access.rs index c340c4edc..2a1b15061 100644 --- a/kanidmd/idm/src/access.rs +++ b/kanidmd/idm/src/access.rs @@ -1475,6 +1475,7 @@ impl<'a> AccessControlsTransaction<'a> for AccessControlsReadTransaction<'a> { // ========================================================================= impl AccessControls { + #![allow(clippy::expect_used)] pub fn new() -> Self { AccessControls { inner: CowCell::new(AccessControlsInner { @@ -1483,12 +1484,8 @@ impl AccessControls { acps_modify: Vec::new(), acps_delete: Vec::new(), }), - /* - acp_related_search_cache: ARCache::new_size( - ACP_RELATED_SEARCH_CACHE_MAX, - ACP_RELATED_SEARCH_CACHE_LOCAL, - ), - */ + // Allow the expect, if this fails it reperesents a programming/development + // failure. acp_resolve_filter_cache: ARCacheBuilder::new() .set_size(ACP_RESOLVE_FILTER_CACHE_MAX, ACP_RESOLVE_FILTER_CACHE_LOCAL) .set_reader_quiesce(true) diff --git a/kanidmd/idm/src/be/dbentry.rs b/kanidmd/idm/src/be/dbentry.rs index 060608207..7244075e5 100644 --- a/kanidmd/idm/src/be/dbentry.rs +++ b/kanidmd/idm/src/be/dbentry.rs @@ -407,7 +407,7 @@ fn from_vec_dbval1(attr_val: Vec) -> Result Result { + pub(crate) fn convert_to_v2(self) -> Result { if let DbEntryVers::V1(dbe) = self.ent { dbe.attrs .into_iter() diff --git a/kanidmd/idm/src/be/idl_sqlite.rs b/kanidmd/idm/src/be/idl_sqlite.rs index a5127da26..bc264cb5a 100644 --- a/kanidmd/idm/src/be/idl_sqlite.rs +++ b/kanidmd/idm/src/be/idl_sqlite.rs @@ -865,7 +865,7 @@ impl IdlSqliteWriteTransaction { admin_error!(?e, "Serde CBOR Error"); OperationError::SerdeCborError }) - .and_then(|dbe: DbEntry| dbe.to_v2()) + .and_then(|dbe: DbEntry| dbe.convert_to_v2()) .and_then(|dbe| { serde_json::to_vec(&dbe) .map(|data| IdRawEntry { id: raw.id, data }) diff --git a/kanidmd/idm/src/be/mod.rs b/kanidmd/idm/src/be/mod.rs index 181189be2..16920d63e 100644 --- a/kanidmd/idm/src/be/mod.rs +++ b/kanidmd/idm/src/be/mod.rs @@ -1494,7 +1494,7 @@ impl<'a> BackendWriteTransaction<'a> { // Migrate any v1 entries to v2 if needed. let dbentries = dbentries .into_iter() - .map(|dbe| dbe.to_v2()) + .map(|dbe| dbe.convert_to_v2()) .collect::, _>>()?; // Now, we setup all the entries with new ids. diff --git a/kanidmd/idm/src/entry.rs b/kanidmd/idm/src/entry.rs index db0a5bc56..ae03d1900 100644 --- a/kanidmd/idm/src/entry.rs +++ b/kanidmd/idm/src/entry.rs @@ -1782,8 +1782,9 @@ impl Entry { let r = vs.insert_checked(value); debug_assert!(r.is_ok()); } else { + #[allow(clippy::expect_used)] let vs = valueset::from_value_iter(std::iter::once(value)) - .expect("Unable to fail - not empty, and only one type!"); + .expect("Unable to fail - non-zero iter, and single value type!"); self.attrs.insert(AttrString::from(attr), vs); } // Doesn't matter if it already exists, equality will replace. diff --git a/kanidmd/idm/src/idm/credupdatesession.rs b/kanidmd/idm/src/idm/credupdatesession.rs index 0e6a42a51..3de701189 100644 --- a/kanidmd/idm/src/idm/credupdatesession.rs +++ b/kanidmd/idm/src/idm/credupdatesession.rs @@ -163,6 +163,9 @@ pub struct CredentialUpdateSessionStatus { mfaregstate: MfaRegStateStatus, } +// We allow Into here because CUStatus is foreign so it's impossible for us to implement From +// in a valid manner +#[allow(clippy::from_over_into)] impl Into for CredentialUpdateSessionStatus { fn into(self) -> CUStatus { CUStatus { diff --git a/kanidmd/idm/src/interval.rs b/kanidmd/idm/src/interval.rs index 306d64b3c..db8737cd6 100644 --- a/kanidmd/idm/src/interval.rs +++ b/kanidmd/idm/src/interval.rs @@ -33,6 +33,9 @@ impl IntervalActor { }); } + // Allow this because result is the only way to map and ? to bubble up, but we aren't + // returning an op-error here because this is in early start up. + #[allow(clippy::result_unit_err)] pub fn start_online_backup( server: &'static QueryServerReadV1, cfg: &OnlineBackup, diff --git a/kanidmd/idm/src/repl/entry.rs b/kanidmd/idm/src/repl/entry.rs index fbe49fc51..655a908a7 100644 --- a/kanidmd/idm/src/repl/entry.rs +++ b/kanidmd/idm/src/repl/entry.rs @@ -111,8 +111,9 @@ impl State { assert!(r.is_ok()); // Reject if it fails? } else { + #[allow(clippy::expect_used)] let vs = valueset::from_value_iter(std::iter::once(value.as_ref().clone())) - .expect("Unable to fail - not empty, and only one type!"); + .expect("Unable to fail - always single value, and only one type!"); attrs.insert(attr.clone(), vs); } } diff --git a/kanidmd/idm/src/value.rs b/kanidmd/idm/src/value.rs index 7e43391d0..16703ad20 100644 --- a/kanidmd/idm/src/value.rs +++ b/kanidmd/idm/src/value.rs @@ -1366,12 +1366,6 @@ impl Value { } } - pub fn to_partialvalue(&self) -> PartialValue { - // Match on self to become a partialvalue. - // self.pv.clone() - unimplemented!(); - } - pub fn to_utf8(self) -> Option { match self { Value::Utf8(s) => Some(s), diff --git a/kanidmd/idm/src/valueset/address.rs b/kanidmd/idm/src/valueset/address.rs index ba436fbd0..7c0db4f7a 100644 --- a/kanidmd/idm/src/valueset/address.rs +++ b/kanidmd/idm/src/valueset/address.rs @@ -49,8 +49,10 @@ impl ValueSetAddress { .collect(); Ok(Box::new(ValueSetAddress { set })) } +} - pub fn from_iter(iter: T) -> Option> +impl FromIterator
for Option> { + fn from_iter(iter: T) -> Option> where T: IntoIterator, { @@ -215,7 +217,10 @@ impl ValueSetEmailAddress { } } - pub fn from_iter(iter: T) -> Option> + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and tuples are always foreign. + #[allow(clippy::should_implement_trait)] + pub fn from_iter(iter: T) -> Option> where T: IntoIterator, { diff --git a/kanidmd/idm/src/valueset/binary.rs b/kanidmd/idm/src/valueset/binary.rs index 8918d8f50..2b2d65fec 100644 --- a/kanidmd/idm/src/valueset/binary.rs +++ b/kanidmd/idm/src/valueset/binary.rs @@ -28,7 +28,10 @@ impl ValueSetPrivateBinary { Ok(Box::new(ValueSetPrivateBinary { set })) } - pub fn from_iter(iter: T) -> Option> + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and vec is foreign + #[allow(clippy::should_implement_trait)] + pub fn from_iter(iter: T) -> Option> where T: IntoIterator>, { @@ -157,7 +160,10 @@ impl ValueSetPublicBinary { Ok(Box::new(ValueSetPublicBinary { map })) } - pub fn from_iter(iter: T) -> Option> + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and tuples are always foreign. + #[allow(clippy::should_implement_trait)] + pub fn from_iter(iter: T) -> Option> where T: IntoIterator)>, { diff --git a/kanidmd/idm/src/valueset/bool.rs b/kanidmd/idm/src/valueset/bool.rs index 2f338037f..3f1efda3c 100644 --- a/kanidmd/idm/src/valueset/bool.rs +++ b/kanidmd/idm/src/valueset/bool.rs @@ -25,6 +25,9 @@ impl ValueSetBool { Ok(Box::new(ValueSetBool { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and bool is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/cid.rs b/kanidmd/idm/src/valueset/cid.rs index d0b4c9f7f..a864cbede 100644 --- a/kanidmd/idm/src/valueset/cid.rs +++ b/kanidmd/idm/src/valueset/cid.rs @@ -34,8 +34,10 @@ impl ValueSetCid { .collect(); Ok(Box::new(ValueSetCid { set })) } +} - pub fn from_iter(iter: T) -> Option> +impl FromIterator for Option> { + fn from_iter(iter: T) -> Option> where T: IntoIterator, { diff --git a/kanidmd/idm/src/valueset/cred.rs b/kanidmd/idm/src/valueset/cred.rs index f5bfbaaea..366149430 100644 --- a/kanidmd/idm/src/valueset/cred.rs +++ b/kanidmd/idm/src/valueset/cred.rs @@ -43,6 +43,9 @@ impl ValueSetCredential { Ok(Box::new(ValueSetCredential { map })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and tuples are always foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, @@ -214,6 +217,9 @@ impl ValueSetIntentToken { Ok(Box::new(ValueSetIntentToken { map })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and tuples are always foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, @@ -375,6 +381,9 @@ impl ValueSetPasskey { Ok(Box::new(ValueSetPasskey { map })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and tuples are always foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, @@ -531,6 +540,9 @@ impl ValueSetDeviceKey { Ok(Box::new(ValueSetDeviceKey { map })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and tuples are always foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/datetime.rs b/kanidmd/idm/src/valueset/datetime.rs index 1ff800dbc..8ea8ab6ee 100644 --- a/kanidmd/idm/src/valueset/datetime.rs +++ b/kanidmd/idm/src/valueset/datetime.rs @@ -33,6 +33,9 @@ impl ValueSetDateTime { Ok(Box::new(ValueSetDateTime { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and offset date time is foreign + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/iname.rs b/kanidmd/idm/src/valueset/iname.rs index ec1a7675f..b44308a97 100644 --- a/kanidmd/idm/src/valueset/iname.rs +++ b/kanidmd/idm/src/valueset/iname.rs @@ -27,6 +27,9 @@ impl ValueSetIname { Ok(Box::new(ValueSetIname { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and str is foreign + #[allow(clippy::should_implement_trait)] pub fn from_iter<'a, T>(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/index.rs b/kanidmd/idm/src/valueset/index.rs index 1f29e1f69..4abd9e1db 100644 --- a/kanidmd/idm/src/valueset/index.rs +++ b/kanidmd/idm/src/valueset/index.rs @@ -26,7 +26,9 @@ impl ValueSetIndex { Ok(Box::new(ValueSetIndex { set })) } - pub fn from_iter(iter: T) -> Option> + // We need to allow this, because there seems to be a bug using it fromiterator in entry.rs + #[allow(clippy::should_implement_trait)] + pub fn from_iter(iter: T) -> Option> where T: IntoIterator, { diff --git a/kanidmd/idm/src/valueset/iutf8.rs b/kanidmd/idm/src/valueset/iutf8.rs index c4c4d7f27..d6b4da6d8 100644 --- a/kanidmd/idm/src/valueset/iutf8.rs +++ b/kanidmd/idm/src/valueset/iutf8.rs @@ -27,6 +27,9 @@ impl ValueSetIutf8 { Ok(Box::new(ValueSetIutf8 { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and str is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter<'a, T>(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/json.rs b/kanidmd/idm/src/valueset/json.rs index 5b6e889cd..c8b6ea7fb 100644 --- a/kanidmd/idm/src/valueset/json.rs +++ b/kanidmd/idm/src/valueset/json.rs @@ -29,6 +29,9 @@ impl ValueSetJsonFilter { Ok(Box::new(ValueSetJsonFilter { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and protofilter is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/nsuniqueid.rs b/kanidmd/idm/src/valueset/nsuniqueid.rs index e993ac5e7..ee1e69984 100644 --- a/kanidmd/idm/src/valueset/nsuniqueid.rs +++ b/kanidmd/idm/src/valueset/nsuniqueid.rs @@ -26,6 +26,9 @@ impl ValueSetNsUniqueId { Ok(Box::new(ValueSetNsUniqueId { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and String is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/oauth.rs b/kanidmd/idm/src/valueset/oauth.rs index cf0ba97be..dd37bb6f1 100644 --- a/kanidmd/idm/src/valueset/oauth.rs +++ b/kanidmd/idm/src/valueset/oauth.rs @@ -32,6 +32,9 @@ impl ValueSetOauthScope { Ok(Box::new(ValueSetOauthScope { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and String is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, @@ -178,6 +181,9 @@ impl ValueSetOauthScopeMap { Ok(Box::new(ValueSetOauthScopeMap { map })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and tuples are always foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator)>, diff --git a/kanidmd/idm/src/valueset/restricted.rs b/kanidmd/idm/src/valueset/restricted.rs index 6fba805ee..9a12bdc18 100644 --- a/kanidmd/idm/src/valueset/restricted.rs +++ b/kanidmd/idm/src/valueset/restricted.rs @@ -25,6 +25,9 @@ impl ValueSetRestricted { Ok(Box::new(ValueSetRestricted { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and String is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/secret.rs b/kanidmd/idm/src/valueset/secret.rs index 1a8cdcc15..2482b8b32 100644 --- a/kanidmd/idm/src/valueset/secret.rs +++ b/kanidmd/idm/src/valueset/secret.rs @@ -25,6 +25,9 @@ impl ValueSetSecret { Ok(Box::new(ValueSetSecret { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and String is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/spn.rs b/kanidmd/idm/src/valueset/spn.rs index 03124aa56..489e27cd5 100644 --- a/kanidmd/idm/src/valueset/spn.rs +++ b/kanidmd/idm/src/valueset/spn.rs @@ -26,6 +26,9 @@ impl ValueSetSpn { Ok(Box::new(ValueSetSpn { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and tuples are always foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/ssh.rs b/kanidmd/idm/src/valueset/ssh.rs index e9b0e2c27..f9d449ce9 100644 --- a/kanidmd/idm/src/valueset/ssh.rs +++ b/kanidmd/idm/src/valueset/ssh.rs @@ -28,6 +28,9 @@ impl ValueSetSshKey { Ok(Box::new(ValueSetSshKey { map })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and tuples are always foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/syntax.rs b/kanidmd/idm/src/valueset/syntax.rs index 8ceade72a..d0d623e5e 100644 --- a/kanidmd/idm/src/valueset/syntax.rs +++ b/kanidmd/idm/src/valueset/syntax.rs @@ -25,8 +25,10 @@ impl ValueSetSyntax { let set = set.map_err(|()| OperationError::InvalidValueState)?; Ok(Box::new(ValueSetSyntax { set })) } +} - pub fn from_iter(iter: T) -> Option> +impl FromIterator for Option> { + fn from_iter(iter: T) -> Option> where T: IntoIterator, { diff --git a/kanidmd/idm/src/valueset/uint32.rs b/kanidmd/idm/src/valueset/uint32.rs index b1eaae14f..af5b05f87 100644 --- a/kanidmd/idm/src/valueset/uint32.rs +++ b/kanidmd/idm/src/valueset/uint32.rs @@ -25,6 +25,9 @@ impl ValueSetUint32 { Ok(Box::new(ValueSetUint32 { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and u32 is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/url.rs b/kanidmd/idm/src/valueset/url.rs index ae3585bad..ec3993edd 100644 --- a/kanidmd/idm/src/valueset/url.rs +++ b/kanidmd/idm/src/valueset/url.rs @@ -25,6 +25,9 @@ impl ValueSetUrl { Ok(Box::new(ValueSetUrl { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and Url is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, diff --git a/kanidmd/idm/src/valueset/uuid.rs b/kanidmd/idm/src/valueset/uuid.rs index 04b56d55b..3c027c6a6 100644 --- a/kanidmd/idm/src/valueset/uuid.rs +++ b/kanidmd/idm/src/valueset/uuid.rs @@ -28,6 +28,9 @@ impl ValueSetUuid { Ok(Box::new(ValueSetUuid { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and uuid is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator, @@ -170,6 +173,9 @@ impl ValueSetRefer { Ok(Box::new(ValueSetRefer { set })) } + // We need to allow this, because rust doesn't allow us to impl FromIterator on foreign + // types, and uuid is foreign. + #[allow(clippy::should_implement_trait)] pub fn from_iter(iter: T) -> Option> where T: IntoIterator,