VersBinarii / bme280-rs

A platform agnostic Rust driver for the Bosch BM[PE]-280
Other
59 stars 73 forks source link

Allow idiomatic error handling by optionally including std::error #13

Closed aatifsyed closed 2 years ago

aatifsyed commented 3 years ago

Allows the user to early return errors with ?, like

fn main() -> Result<(), Box<dyn Error>> {
    let opt = Opt::from_args();
    let i2c_bus = I2cdev::new(opt.i2c_bus_path)?; // here
    let mut sensor = BME280::new(i2c_bus, opt.i2c_address, Delay);
    sensor.init()?; // here
    let measurements = sensor.measure()?; //here
    println!("{:?}", measurements);
    Ok(())
}
VersBinarii commented 2 years ago

I understand it has been 14 months but any chance you could rebase this on master? :)

aatifsyed commented 2 years ago

:(

Thanks for implementing!