Fix build on FreeBSD
On FreeBSD rlims are i64 (for legacy reasons) which doesn't have an
Into for u64. The values are never negative anyway so we can just
try_into() and unwrap.
@@ -63,6 +63,7 @@ enum RlimitResource {
#[cfg(unix)]
fn getrlimit(resource: RlimitResource) -> Result<u64, DiagnosticError> {
use libc::rlimit;
+ use std::convert::TryInto;
let mut limits = rlimit {
rlim_cur: 0,
@@ -77,5 +78,8 @@ fn getrlimit(resource: RlimitResource) -> Result<u64, DiagnosticError> {
let retcode = unsafe { libc::getrlimit(resource, &mut limits as *mut rlimit) };
nix::errno::Errno::result(retcode).map_err(DiagnosticError::UnixError)?;
- Ok(limits.rlim_cur.into())
+ Ok(limits
+ .rlim_cur
+ .try_into()
+ .expect("rlim always converts to a u64"))
}
