Make it possible to construct DynPin from scratch#482
Make it possible to construct DynPin from scratch#4829names wants to merge 1 commit intorp-rs:mainfrom
Conversation
|
I finally got around to testing this... I don't think it's going to be enough; ultimately what I need is "a way to pass in The SPI peripheral doesn't seem to take in any pins to initialize, so I can safely use that with |
That one looks like a separate (but related) issue: I think this requirement is too strict. I don't see an inherent reason why it shouldn't be possible to construct an I2C peripheral with DynPins. Of course, that either needs some run-time checks (not zero cost - but really not expensive either), or would allow the user to create an I2C peripheral with nonsensical pins. Even the latter wouldn't be a catastrophe, it's not unsound or such, it just won't work. |
| @@ -305,7 +305,7 @@ impl DynPin { | |||
| /// must be at most one corresponding [`DynPin`] in existence at any given | |||
| /// time. Violating this requirement is `unsafe`. | |||
There was a problem hiding this comment.
Just a side note, as it wasn't changed in this PR: The comment "Violating this requirement is unsafe" is a little bit off. The function is unsafe because the caller must guarantee that DynPins are unique. Violating such a condition is not unsafe, it's plain wrong. It may cause UB, or other bugs. But saying that violation the safety conditions of an unsafe function is unsafe doesn't convey any useful meaning.
Basic functionality for #481