Skip to content

add is_extended default impl for CAN frame #663

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions embedded-can/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Added `core::error::Error` implementations for every custom `impl Error`
- Increased MSRV to 1.81 due to `core::error::Error`
- Added `is_extended` default implementation for CAN frame.

## [v0.4.1] - 2022-09-28

Expand Down
7 changes: 6 additions & 1 deletion embedded-can/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ pub trait Frame: Sized {
fn new_remote(id: impl Into<Id>, dlc: usize) -> Option<Self>;

/// Returns true if this frame is an extended frame.
fn is_extended(&self) -> bool;
fn is_extended(&self) -> bool {
match self.id() {
Id::Standard(_) => false,
Id::Extended(_) => true,
}
}

/// Returns true if this frame is a standard frame.
fn is_standard(&self) -> bool {
Expand Down