-
Notifications
You must be signed in to change notification settings - Fork 221
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
Add PeripheralRef::map_into
#2326
Conversation
b2e4f64
to
4b9ef27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
This comment was marked as resolved.
This comment was marked as resolved.
7386ec0
to
0040c40
Compare
@@ -448,7 +448,7 @@ pub trait PeripheralOutput: PeripheralSignal { | |||
} | |||
|
|||
/// Trait implemented by pins which can be used as inputs. | |||
pub trait InputPin: Pin + PeripheralInput { | |||
pub trait InputPin: Pin + PeripheralInput + Into<AnyPin> + 'static { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new bounds should have been added to Pin
but that makes RtcPin
no longer dyn compatible, which is a breaking change I do not wish to tackle here.
@@ -257,6 +298,17 @@ mod peripheral_macros { | |||
} | |||
} | |||
|
|||
#[doc(hidden)] | |||
#[macro_export] | |||
macro_rules! into_mapped_ref { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding this macro here, instead of in a PR that actually uses it, because I'm introducing the map_into
method(s) here. Can be moved if it's an issue.
/// This converts from `Peripheral<P = T>` to `Peripheral<P = U>`, | ||
/// using an `Into` impl to convert from `T` to `U`. | ||
#[inline] | ||
fn map_into<U>(self) -> U |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is supposed to be redundant, but for some reason converting through PeripheralRef::map_into requires additional lifetime bounds that I wanted to avoid.
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
This is lifted from embassy-hal-internal to make it a bit nicer to implement peripheral type erasure.