Implement TryFrom for a variety of types#139
Implement TryFrom for a variety of types#139briansmith merged 2 commits intobriansmith:masterfrom mattmahn:try-from
Conversation
src/time.rs
Outdated
| @@ -47,9 +44,7 @@ impl Time { | |||
| /// ``` | |||
| #[cfg(feature = "std")] | |||
| pub fn try_from(time: std::time::SystemTime) -> Result<Time, ring::error::Unspecified> { | |||
There was a problem hiding this comment.
Go ahead and just remove this function.
There was a problem hiding this comment.
Sounds good; I kept it just in case needing to add use std::convert::TryFrom would be considered a breaking change
Codecov Report
@@ Coverage Diff @@
## master #139 +/- ##
==========================================
- Coverage 73.91% 73.76% -0.15%
==========================================
Files 14 14
Lines 1357 1361 +4
==========================================
+ Hits 1003 1004 +1
- Misses 354 357 +3
Continue to review full report at Codecov.
|
briansmith
left a comment
There was a problem hiding this comment.
Thanks! I'm glad this cleanup is being done. Just a few small details to clean up and then I'll merge this.
src/webpki.rs
Outdated
| /// `cert_der`. | ||
| pub fn from(cert_der: &'a [u8]) -> Result<Self, Error> { | ||
| EndEntityCert::try_from(cert_der) | ||
| } |
There was a problem hiding this comment.
Sorry I wasn't clear in the earlier review. We should also delete this alternative so that TryFrom is the only way to construct a EndEntityCert.
tests/integration.rs
Outdated
| #[cfg(feature = "std")] | ||
| #[test] | ||
| fn time_constructor() { | ||
| use std::convert::TryFrom; |
There was a problem hiding this comment.
Again. let's use core:: instead of std:: consistently.
src/webpki.rs
Outdated
| } | ||
|
|
||
| impl<'a> EndEntityCert<'a> { | ||
| impl<'a> TryFrom<&'a [u8]> for EndEntityCert<'a> { |
There was a problem hiding this comment.
NIT: In the other implementation you used impl ... core::convert::TryFrom and here you used use ::cure::convert::TryFrom and then the impl is unqualified. I think we should be consistent.
This adds TryFrom implementations for a variety of types that already had equivalent implementations, but outside of an
imply TryFrom.I'm unsure about adding
#[deprecated], since those who elevate deprecation warning to compile error may have touse core::convert::TryFrom.related to #73