Implement as_vec for OID #22

Merged
zartarn15 merged 1 commits from master into master 2021-05-18 08:05:09 -07:00
zartarn15 commented 2021-05-17 09:57:06 -07:00 (Migrated from github.com)

Change-Id: I29d59b77b541454007343488f8f809c3052ad3e3

Change-Id: I29d59b77b541454007343488f8f809c3052ad3e3
acw commented 2021-05-17 13:24:22 -07:00 (Migrated from github.com)

Cool, thanks for the patch!

I'm curious, though, about why do this as a specific method, rather than as an instance of TryFrom? TryFrom might require inventing an overflow error of some sort, but would fit into the general scheme. You might be able to do something fancy with ToPrimitive to allow people to also convert to other primitive types (i64,usize,etc.)

Oh, and maybe we can do away with the indexing in the loop:

        for val in self.0.iter() {
            let bn = val.to_u64()?;
            vec.push(bn.to_u64()?);
        }
Cool, thanks for the patch! I'm curious, though, about why do this as a specific method, rather than as an instance of `TryFrom`? `TryFrom` might require inventing an overflow error of some sort, but would fit into the general scheme. You might be able to do something fancy with `ToPrimitive` to allow people to also convert to other primitive types (`i64`,`usize`,etc.) Oh, and maybe we can do away with the indexing in the loop: ``` for val in self.0.iter() { let bn = val.to_u64()?; vec.push(bn.to_u64()?); } ```
zartarn15 commented 2021-05-18 02:52:39 -07:00 (Migrated from github.com)

Thanks for review.
Updated as you suggested.

Thanks for review. Updated as you suggested.
acw commented 2021-05-18 08:05:03 -07:00 (Migrated from github.com)

Awesome!

Awesome!
acw commented 2021-05-18 08:10:11 -07:00 (Migrated from github.com)

I've pushed this to crates.io as 0.5.3, if you're using it in a project somewhere. Thanks again!

I've pushed this to `crates.io` as 0.5.3, if you're using it in a project somewhere. Thanks again!
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: acw/simple_asn1#22