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

Add PeripheralRef::map_into #2326

Merged
merged 3 commits into from
Oct 16, 2024
Merged

Add PeripheralRef::map_into #2326

merged 3 commits into from
Oct 16, 2024

Conversation

bugadani
Copy link
Contributor

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 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the Migration Guide.
  • My changes are in accordance to the esp-rs API guidelines

Extra:

Pull Request Details 📖

Description

This is lifted from embassy-hal-internal to make it a bit nicer to implement peripheral type erasure.

@bugadani bugadani marked this pull request as draft October 10, 2024 11:20
@bugadani bugadani force-pushed the map-into branch 2 times, most recently from b2e4f64 to 4b9ef27 Compare October 10, 2024 13:09
@bugadani bugadani marked this pull request as ready for review October 10, 2024 13:10
Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bugadani bugadani mentioned this pull request Oct 10, 2024
6 tasks
Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@bugadani

This comment was marked as resolved.

@bugadani bugadani marked this pull request as draft October 12, 2024 08:16
@bugadani bugadani force-pushed the map-into branch 3 times, most recently from 7386ec0 to 0040c40 Compare October 14, 2024 09:36
@@ -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 {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@bugadani bugadani marked this pull request as ready for review October 14, 2024 09:41
@bugadani bugadani enabled auto-merge October 16, 2024 13:21
@bugadani bugadani added this pull request to the merge queue Oct 16, 2024
Merged via the queue into esp-rs:main with commit 472d5f9 Oct 16, 2024
28 checks passed
@bugadani bugadani deleted the map-into branch October 16, 2024 13:52
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.

3 participants