Skip to content

Beta / 2018 Edition compatibility complications #11

Closed
@therealprof

Description

@therealprof

I was just checking how well my crates would play with the 2018 edition and I was able to work around most quirks except for a few with the most major probably being that it seems to be impossible to share peripherals via the good old Mutex<RefCell<Option<_>>> static mechanism due to the inavailability of const_fn:

error[E0015]: calls in statics are limited to tuple structs and tuple variants
  --> examples/i2c_haldriver_printmagserial.rs:31:62
   |
31 | static MAG3110: Mutex<RefCell<Option<Mag3110<I2c<TWI1>>>>> = Mutex::new(RefCell::new(None));
   |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: a limited form of compile-time function evaluation is available on a nightly compiler via `const fn`
  --> examples/i2c_haldriver_printmagserial.rs:31:62
   |
31 | static MAG3110: Mutex<RefCell<Option<Mag3110<I2c<TWI1>>>>> = Mutex::new(RefCell::new(None));
   |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Is there any good workaround we can use here? Not being able to pass around peripherals and data safely into/out of interrupt handlers would be pretty bad, IMHO.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions