12
12
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
13
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
14
15
- #[ cfg( feature = "alloc" ) ]
16
- use alloc:: vec:: Vec ;
17
-
18
- use super :: dns_name:: { self , DnsNameRef } ;
19
- #[ cfg( feature = "alloc" ) ]
20
- use super :: dns_name:: { GeneralDnsNameRef , WildcardDnsNameRef } ;
15
+ use super :: dns_name:: { self , DnsNameRef , GeneralDnsNameRef , WildcardDnsNameRef } ;
21
16
use super :: ip_address:: { self , IpAddrRef } ;
22
17
use super :: name:: SubjectNameRef ;
23
18
use crate :: der:: { self , FromDer } ;
@@ -317,22 +312,16 @@ impl<'a> Iterator for NameIterator<'a> {
317
312
}
318
313
}
319
314
320
- #[ cfg( feature = "alloc" ) ]
321
315
pub ( crate ) fn list_cert_dns_names < ' names > (
322
316
cert : & ' names crate :: EndEntityCert < ' names > ,
323
317
) -> impl Iterator < Item = & ' names str > {
324
318
let cert = & cert. inner ( ) ;
325
- let mut names = Vec :: new ( ) ;
326
-
327
- NameIterator :: new ( Some ( cert. subject ) , cert. subject_alt_name ) . for_each ( |result| {
328
- let name = match result {
329
- Ok ( name) => name,
330
- Err ( _) => return ,
331
- } ;
319
+ NameIterator :: new ( Some ( cert. subject ) , cert. subject_alt_name ) . filter_map ( |result| {
320
+ let name = result. ok ( ) ?;
332
321
333
322
let presented_id = match name {
334
323
GeneralName :: DnsName ( presented) => presented,
335
- _ => return ,
324
+ _ => return None ,
336
325
} ;
337
326
338
327
let dns_name = DnsNameRef :: try_from_ascii ( presented_id. as_slice_less_safe ( ) )
@@ -344,12 +333,11 @@ pub(crate) fn list_cert_dns_names<'names>(
344
333
345
334
// if the name could be converted to a DNS name, add it; otherwise,
346
335
// keep going.
347
- if let Ok ( name) = dns_name {
348
- names. push ( name. into ( ) )
336
+ match dns_name {
337
+ Ok ( name) => Some ( name. into ( ) ) ,
338
+ _ => None ,
349
339
}
350
- } ) ;
351
-
352
- names. into_iter ( )
340
+ } )
353
341
}
354
342
355
343
// It is *not* valid to derive `Eq`, `PartialEq, etc. for this type. In
0 commit comments