safe-goto

Crates.iosafe-goto
lib.rssafe-goto
version0.2.0
sourcesrc
created_at2022-12-02 18:44:54.189575
updated_at2022-12-04 01:10:32.102976
descriptionEmulating a safe goto-like instruction in Rust in the spirit of the "Safe goto with value" pre-RFC from IRLO
homepage
repository
max_upload_size
id728548
size49,772
(oskgo)

documentation

README

safe-goto

Emulating a safe goto-like instruction in Rust in the spirit of the "Safe goto with value" pre-RFC from IRLO

The crate contains a single macro, safe_goto, which emulates goto with value using a loop wrapping a match on an enum.

Goals

The purpose of this crate is two-fold:

  • Provide a test-bed for experimenting with patterns involving a safe version of goto in Rust
  • Highlight areas where the rust compiler has room to improve its branch related optimizations

Non-goals:

  • The crate does not aim for maximal performance. Doing inline assembly defeats the purpose
  • The crate does not aim to be a stable foundation for others to build upon. The syntax may change to reflect what might eventually be implemented in the stdlib or as part of the language. Also, the macro is very brittle since it has to handle near-arbitrary rust code

Examples

The tests and examples contain some examples of the functionality. You can have a look at the expanded macro using tools like cargo-expand.

Commit count: 0

cargo fmt