Skip to content

Conversation

walkie
Copy link
Contributor

@walkie walkie commented Jan 5, 2022

This is a major refactor of the runtime interface which makes it much easier to program against in a generic way. The most obvious changes are:

  1. The interface is no longer split into sync/unsync variants.
  2. The runtime interface no longer requires a lifetime annotation on the machine type.

It's not all roses though. The new approach uses a set of trait bounds on the Machine type, and these must often be propagated to use sites. Also the type annotations required on callback arguments have gotten a little bit harrier. See the documentation for details.

Both of these issues are situations where Rust should be able to infer the types/bounds but can't currently, so these drawbacks may disappear in the future as Rust improves.

walkie added 6 commits January 1, 2022 01:35
This is a major refactor of the runtime interface which makes it *much* easier to program against in a generic way. The most obvious changes are (1) the interface is no longer split into sync/unsync variants, (2) the runtime interface no longer requires a lifetime annotation on the machine type.

The type annotations required on callback arguments have gotten a little bit harrier... I really wish Rust was better at inferring the types of closure arguments--in this case all the info is obviously there to do it.

The runtime interface and its demos and tests have been updated and are working, but the code generator and integration tests have not been updated yet, so CI is expected to fail.
This change was needed so that the Send and Sync traits will propagate to structs that contain values of these associated types, when applicable. Unfortunately, Rust can't automatically propagate the associated type bounds, which means they need to be propagated everywhere that the Machine trait is used. Quite annoying from an ergonomic perspective...

Here's the RFC to add the ability to automatically propagate trait bounds to Rust in the future: rust-lang/rust#52662
@walkie walkie merged commit d2bab1d into main Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant