diff --git a/CHANGELOG.md b/CHANGELOG.md index 316446f..d4f57cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.4.0] - 2024-04-01 + +### Added + +- CI setup now covers almost all supported Tier 1 and Tier 2 platform targets + +### Changed + +- Minimum Supported Rust version set to `1.67.0` +- Rust edition set to "2021" + +### Fixed + +- Handle edge cases for POSIX systems (#14) +- docs.rs documentation build + ## [0.3.1] - 2020-02-28 ### Fixed diff --git a/src/lib.rs b/src/lib.rs index c22faad..7136064 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,15 +8,12 @@ Set and get the host name: ```rust,no_run # use std::io; # use std::ffi::OsStr; -# fn try_main() -> io::Result<()> { +# fn main() -> io::Result<()> { hostname::set("potato")?; let new_name = hostname::get()?; assert_eq!(new_name, OsStr::new("potato")); # Ok(()) # } -# fn main() { -# try_main().unwrap(); -# } ``` "# )] @@ -27,14 +24,11 @@ Get the host name: ```rust,no_run # use std::io; # use std::ffi::OsStr; -# fn try_main() -> io::Result<()> { +# fn main() -> io::Result<()> { let name = hostname::get()?; println!("{:?}", name); # Ok(()) # } -# fn main() { -# try_main().unwrap(); -# } ``` "# )] @@ -54,6 +48,7 @@ println!("{:?}", name); unused_import_braces, unused_results )] +#![cfg_attr(docsrs, feature(doc_cfg))] use cfg_if::cfg_if; @@ -80,13 +75,10 @@ cfg_if! { /// /// ```rust /// # use std::io; -/// # fn try_main() -> io::Result<()> { +/// # fn main() -> io::Result<()> { /// let name = hostname::get()?; /// # Ok(()) /// # } -/// # fn main() { -/// # try_main().unwrap(); -/// # } /// ``` /// /// ## Errors @@ -108,13 +100,10 @@ pub fn get() -> io::Result { ```rust,no_run # use std::io; -# fn try_main() -> io::Result<()> { +# fn main() -> io::Result<()> { hostname::set("potato")?; # Ok(()) # } -# fn main() { -# try_main().unwrap(); -# } ``` "# )] diff --git a/src/windows.rs b/src/windows.rs index ab69829..dfba8f9 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -6,12 +6,12 @@ use std::io; use std::os::windows::ffi::OsStrExt; use std::os::windows::ffi::OsStringExt; -use windows::Win32::System::SystemInformation::ComputerNamePhysicalDnsHostname; +use windows::core::PWSTR; +use windows::Win32::System::SystemInformation::{ + ComputerNamePhysicalDnsHostname, GetComputerNameExW, +}; pub fn get() -> io::Result { - use windows::core::PWSTR; - use windows::Win32::System::SystemInformation::GetComputerNameExW; - let mut size = 0; unsafe { // Don't care much about the result here,