@@ -159,8 +159,7 @@ impl CredentialApi for SsCredential {
159
159
/// returns an [Ambiguous](ErrorCode::Ambiguous)
160
160
/// error with a credential for each matching item.
161
161
fn get_password ( & self ) -> Result < String > {
162
- let passwords: Vec < String > = self . map_matching_items ( get_item_password, true ) ?;
163
- Ok ( passwords[ 0 ] . clone ( ) )
162
+ Ok ( self . map_matching_items ( get_item_password, true ) ?. remove ( 0 ) )
164
163
}
165
164
166
165
/// Gets the secret on a unique matching item, if it exists.
@@ -171,8 +170,7 @@ impl CredentialApi for SsCredential {
171
170
/// returns an [Ambiguous](ErrorCode::Ambiguous)
172
171
/// error with a credential for each matching item.
173
172
fn get_secret ( & self ) -> Result < Vec < u8 > > {
174
- let secrets: Vec < Vec < u8 > > = self . map_matching_items ( get_item_secret, true ) ?;
175
- Ok ( secrets[ 0 ] . clone ( ) )
173
+ Ok ( self . map_matching_items ( get_item_secret, true ) ?. remove ( 0 ) )
176
174
}
177
175
178
176
/// Get attributes on a unique matching item, if it exists
@@ -280,8 +278,9 @@ impl SsCredential {
280
278
/// Construct a credential for this credential's underlying matching item,
281
279
/// if there is exactly one.
282
280
pub fn new_from_matching_item ( & self ) -> Result < Self > {
283
- let credentials = self . map_matching_items ( Self :: new_from_item, true ) ?;
284
- Ok ( credentials[ 0 ] . clone ( ) )
281
+ Ok ( self
282
+ . map_matching_items ( Self :: new_from_item, true ) ?
283
+ . remove ( 0 ) )
285
284
}
286
285
287
286
/// If there are multiple matching items for this credential, get all of their passwords.
@@ -324,8 +323,10 @@ impl SsCredential {
324
323
let attributes: HashMap < & str , & str > = self . search_attributes ( false ) . into_iter ( ) . collect ( ) ;
325
324
let search = ss. search_items ( attributes) . map_err ( decode_error) ?;
326
325
let count = search. locked . len ( ) + search. unlocked . len ( ) ;
327
- if count == 0 && matches ! ( self . target. as_ref( ) , Some ( t) if t == "default" ) {
328
- return self . map_matching_legacy_items ( & ss, f, require_unique) ;
326
+ if count == 0 {
327
+ if let Some ( "default" ) = self . target . as_deref ( ) {
328
+ return self . map_matching_legacy_items ( & ss, f, require_unique) ;
329
+ }
329
330
}
330
331
if require_unique {
331
332
if count == 0 {
0 commit comments