Skip to content

use byte literals instead of casting char to u8 in exercise examples#1017

Merged
coriolinus merged 1 commit intomasterfrom
example-cast-char-truncates
Nov 18, 2020
Merged

use byte literals instead of casting char to u8 in exercise examples#1017
coriolinus merged 1 commit intomasterfrom
example-cast-char-truncates

Conversation

@coriolinus
Copy link
Copy Markdown
Member

Helps address #1012.

let shift = key_arr[i % key_arr.len()] as i8 - 'a' as i8;
let n = ((c as i8 - 'a' as i8 + dir * shift) % 26 + 26) % 26;
o.push(char::from('a' as u8 + n as u8));
let n = ((c as i8 - b'a' as i8 + dir * shift) % 26 + 26) % 26;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think Clippy had anything to say about this one, but let's do it anyway for consistency

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Exactly.

@coriolinus coriolinus merged commit a84736d into master Nov 18, 2020
@coriolinus coriolinus deleted the example-cast-char-truncates branch November 18, 2020 11:24
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