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

Impl From for Message for [u8;N] and u8 #352

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tosti007
Copy link

No description provided.

@@ -229,6 +229,12 @@ impl<const N: usize> From<[u8; N]> for Message {
}
}

impl From<u8> for Message {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this impl really useful? Conceptually it doesn't make a lot of sense...

Copy link
Author

Choose a reason for hiding this comment

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

The usecase I personally found it sending a status response, i.e. a boolean, back to the other client. In which case it currently looks roughly like:

[struct.success as u8].as_slice()

Which would then be:

struct.success as u8

Initially I wanted to implement the From<T> for Message for anything that's either Into<u8> or AsRef<[u8]>, but that currently does not work without removing the impls for Box and Vec.

Copy link
Contributor

Choose a reason for hiding this comment

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

With your other impl it's just [struct.success as u8] which seems good enough.

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