rust-embedded / rust-embedded/cortex-m

Make Peripherals::steal() zero cost

Open
#356 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1k
Forks
202
Avg merge
6d 2h
Merged PRs (30d)
2

Description

Peripherals::steal() has a write to a static mut: https://github.com/rust-embedded/cortex-m/blob/6b013138b734b9bbeb24a345f75d2bcc1c69fa8d/src/peripheral/mod.rs#L180

I expected it to be zero-cost, just constructing and returning the Peripherals which is a noop since it is ZST. This was a bit surprising.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/peripheral/mod.rs around line 180 and inspect how Peripherals::steal() constructs and returns the zero-sized Peripherals value. Confirm the implementation no longer performs the static mut write and remains safe under its existing contract; the completed change should make the function zero-cost.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
embedded-iot
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.