Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pins owned instead of mut borrowed #2

Merged
merged 2 commits into from
Jun 10, 2020

Conversation

kolen
Copy link
Contributor

@kolen kolen commented Dec 25, 2019

Currently, PCD8544 struct mutably borrows pins that it uses:

pcd8544/src/lib.rs

Lines 39 to 45 in fdaae48

pub struct PCD8544<'a> {
clk: &'a mut OutputPin,
din: &'a mut OutputPin,
dc: &'a mut OutputPin,
ce: &'a mut OutputPin,
rst: &'a mut OutputPin,
light: &'a mut OutputPin,

While that might look like a good idea, putting these pins and PCD8544 to some struct is almost impossible in Rust's type system, requiring sophisticated hacks like rental or something based on Pin, which is high-end type system magic.

Most driver crates I've seen own pins.

This change is backwards-incompatible.

See also:

Same discussion in another your crate: kellerkindt/w5500#13

@kellerkindt
Copy link
Owner

Thanks! Sorry for the late response.
I'll upload a new version to crates.io in a few minutes, but I'll bump the version to 0.2.0 nonetheless... just to be extra explicit about the change :)

@kellerkindt kellerkindt merged commit 29388c3 into kellerkindt:master Jun 10, 2020
kellerkindt added a commit that referenced this pull request Jul 24, 2021
Support for spliting measures to integer and fraction.
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.

2 participants