Provide try_from only on 1.34+

This commit is contained in:
David Tolnay 2019-07-17 12:21:18 -07:00
parent 92e0b62c6b
commit f249e72162
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 9 additions and 1 deletions

View File

@ -69,7 +69,12 @@ fn main() {
println!("cargo:rustc-cfg=num_nonzero");
}
// TryFrom and Atomic types stabilized in Rust 1.34:
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#library-stabilizations
if minor >= 34 {
println!("cargo:rustc-cfg=core_try_from");
// Whitelist of archs that support std::sync::atomic module. Ideally we
// would use #[cfg(target_has_atomic = "...")] but it is not stable yet.
// Instead this is based on rustc's src/librustc_target/spec/*.rs.

View File

@ -1,5 +1,5 @@
pub use lib::clone::Clone;
pub use lib::convert::{From, Into, TryFrom};
pub use lib::convert::{From, Into};
pub use lib::default::Default;
pub use lib::fmt::{self, Formatter};
pub use lib::marker::PhantomData;
@ -11,6 +11,9 @@ pub use self::string::from_utf8_lossy;
#[cfg(any(feature = "alloc", feature = "std"))]
pub use lib::{ToString, Vec};
#[cfg(core_try_from)]
pub use lib::convert::TryFrom;
mod string {
use lib::*;