-
Notifications
You must be signed in to change notification settings - Fork 24
Convert Ascii
into an enum.
#14
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
Conversation
@@ -52,13 +184,13 @@ impl Ascii { | |||
/// Converts an ascii character into a `u8`. | |||
#[inline] | |||
pub fn as_byte(&self) -> u8 { | |||
self.chr | |||
unsafe{ transmute(*self) } |
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 conversion doesn't need an unsafe block because *self as u8
works as expected.
I basically agree with the naming convention you chose, only minor discussion:
The public interface isn't changed, in fact there is a new way to initialize |
Allows static initialization, nicer pattern matches and comparisons. Naming conventions: * alphabetic: just use it. breaks CamelCase convention, but worth it for simplicity. * digits: prepend _ to make them valid identifiers, but still short. * non-alphanumeric but visible: Use Wikipedia names CamelCased, but remove -Mark endings. * rarely used control codes: use uppercase acronym to deter use. * more commonly used control codes: Expand and CamelCase acronym to preserve meaning, eg LineFeed not NewLine or LFneBreak. I'm not certain which control codes should be expanded; Currently BEL and DEL are, but should they? I'm not sure whether this is a breaking change.
Control code names get expanded iff they have an escape code in [this table](. Else the two-or-three letter uppercase code name is used. )# modified: src/ascii.rs
Rebased on master to use wrapping_sub. Also added rustdocfor each enum variant in the first commit. I decided to categorize control codes on whether they have an escape code listed in this table While not rustic, I think uppercase names prevent confusion:
|
I'm fine with your PR, thanks for your work! I like the categorization based on the existence of an escape code, that makes it easier to guess how the variant is named. Your arguments also convinced me, that we should keep uppercase names for control codes. Indeed I've never seen control codes in CamelCase notation. One minor point is that you used block comments I can make that little change myself and thank your for your PR! |
Do you need the changes in this PR urgently? If so I will do a release, else I'll wait batching up some more changes I'm currently working on. ( #13 for example) |
No, I don't need the changes, and I'm working on another one.
|
Oh, right, maybe I'll revert my changes that modify the doc-comments before the release. |
Allows static initialization, nicer pattern matches and comparisons.
Naming conventions:
I'm not certain which control codes should be expanded; Currently BEL and DEL are, but should they?
I'm not sure whether this is a breaking change.