As the try_trait_v2 lingers on, perhaps we can just ignore the lint with something like:
use std::fmt;
const ERROR_INSTALL_FAILURE: Error =
Error(unsafe { std::num::NonZero::<u32>::new_unchecked(1603) });
#[derive(Debug)]
#[repr(transparent)]
pub struct Error(std::num::NonZero<u32>);
impl std::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, f: &'_ mut fmt::Formatter) -> fmt::Result {
f.write_str(&self.0.to_string())
}
}
pub type Result<T> = std::result::Result<T, Error>;
#[allow(improper_ctypes_definitions)]
#[no_mangle]
pub extern "C" fn print_size() -> Result<()> {
println!("{}", std::mem::size_of::<Result<()>>());
Err(ERROR_INSTALL_FAILURE)
}
fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
Ok(print_size()?)
}
As the
try_trait_v2lingers on, perhaps we can just ignore the lint with something like: