diff options
author | Trevor Spiteri <tspiteri@ieee.org> | 2019-01-21 23:46:25 +0100 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-01-22 12:13:53 -0500 |
commit | 802bc11cd2a0a7a8bfdad5749baf58683ea0bcf3 (patch) | |
tree | f904892b0af7c728516b73d1e447ca21a5f06014 | |
parent | fe8c8ed12c9fe1e467109c9dc3d33d2da36168d6 (diff) | |
download | byteorder-802bc11cd2a0a7a8bfdad5749baf58683ea0bcf3.tar.gz |
build: add back support for Rust 1.12
In older versions of Rust, the build.rs file is not auto-detected, so we
add it to the Cargo.toml. Moreover, the existing build.rs was not
compatible with older Rust versions because of the use of eprintln! and
short-hand struct initialization. We fix that.
Closes #140, Closes #141
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | build.rs | 15 |
2 files changed, 11 insertions, 5 deletions
@@ -11,6 +11,7 @@ categories = ["encoding", "parsing"] keywords = ["byte", "endian", "big-endian", "little-endian", "binary"] license = "Unlicense OR MIT" exclude = ["/ci/*"] +build = "build.rs" [lib] name = "byteorder" @@ -1,12 +1,17 @@ use std::env; use std::ffi::OsString; +use std::io::{self, Write}; use std::process::Command; fn main() { let version = match Version::read() { Ok(version) => version, Err(err) => { - eprintln!("failed to parse `rustc --version`: {}", err); + writeln!( + &mut io::stderr(), + "failed to parse `rustc --version`: {}", + err + ).unwrap(); return; } }; @@ -57,7 +62,7 @@ impl Version { } num.push(c); } - let major = num.parse::<u32>().map_err(|e| e.to_string())?; + let major = try!(num.parse::<u32>().map_err(|e| e.to_string())); num.clear(); for c in parts[1].chars() { @@ -66,7 +71,7 @@ impl Version { } num.push(c); } - let minor = num.parse::<u32>().map_err(|e| e.to_string())?; + let minor = try!(num.parse::<u32>().map_err(|e| e.to_string())); num.clear(); for c in parts[2].chars() { @@ -75,8 +80,8 @@ impl Version { } num.push(c); } - let patch = num.parse::<u32>().map_err(|e| e.to_string())?; + let patch = try!(num.parse::<u32>().map_err(|e| e.to_string())); - Ok(Version { major, minor, patch }) + Ok(Version { major: major, minor: minor, patch: patch }) } } |