Skip to content

Commit 7f3368d

Browse files
committed
Use VecDeque and pop from wrong when iterating
The order was reversed after parsing a cert.
1 parent 6f2b01f commit 7f3368d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

rcgen/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ println!("{}", key_pair.serialize_pem());
3333
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
3434
#![warn(unreachable_pub)]
3535

36+
use std::collections::VecDeque;
3637
use std::fmt;
3738
use std::hash::Hash;
3839
use std::net::IpAddr;
@@ -298,7 +299,7 @@ See also the RFC 5280 sections on the [issuer](https://tools.ietf.org/html/rfc52
298299
and [subject](https://tools.ietf.org/html/rfc5280#section-4.1.2.6) fields.
299300
*/
300301
pub struct DistinguishedName {
301-
entries: Vec<(DnType, DnValue)>,
302+
entries: VecDeque<(DnType, DnValue)>,
302303
}
303304

304305
impl DistinguishedName {
@@ -345,7 +346,7 @@ impl DistinguishedName {
345346
/// assert_eq!(dn.get(&DnType::CommonName).get(0), Some(&DnValue::PrintableString("Master Cert".try_into().unwrap())).as_ref());
346347
/// ```
347348
pub fn push(&mut self, ty: DnType, s: impl Into<DnValue>) {
348-
self.entries.push((ty, s.into()));
349+
self.entries.push_front((ty, s.into()));
349350
}
350351

351352
#[cfg(feature = "x509-parser")]
@@ -397,7 +398,7 @@ impl Iterator for DistinguishedName {
397398
type Item = (DnType, DnValue);
398399

399400
fn next(&mut self) -> Option<Self::Item> {
400-
self.entries.pop()
401+
self.entries.pop_back()
401402
}
402403

403404
fn size_hint(&self) -> (usize, Option<usize>) {

0 commit comments

Comments
 (0)