-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Return Option rather than fail for slice_shift_char
and {shift,pop}_{char,byte}
#12797
Conversation
@@ -3600,6 +3612,22 @@ mod tests { | |||
} | |||
|
|||
#[test] | |||
fn test_slice_shift_char() { | |||
let data = "ประเทศไทย中"; | |||
let (cc, rest) = data.slice_shift_char(); |
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 test could be assert_eq!(data.slice_shift_char(), (Some('ป'), "ระเทศไทย中"))
(and below too).
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.
Done
This looks great, thanks! Just a small comment from me and @huonw, and I think this is good to go. |
@@ -3148,7 +3159,7 @@ mod tests { | |||
let mut data = ~"ประเทศไทย中华"; | |||
let cc = data.pop_char(); | |||
assert_eq!(~"ประเทศไทย中", data); | |||
assert_eq!('华', cc); | |||
assert_eq!('华', cc.unwrap()); |
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.
Could you convert all of the unwrap
s you added to comparing against Some('...')
? It makes test failures much easier to diagnose.
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.
Done
…yte` and `pop_byte` to return an Option instead of failing
Along the lines of `shift_ref` and `pop_ref`.
…data, r=Veykril feat: support associated values in "Generate Enum Variant" assist This change adds support for associated values to the "Generate Enum Variant" assist. I've split the implementation out into 4 steps to make code review easier: - Add "add_variant" support to the structural ast editing system in `edit_in_place` - Migrate `generate_enum_variant` to use structural ast editing instead of string manipulation - Support tuple fields - Support record fields Please let me know if I should leave the commits as-is, or squash before merging. Fixes rust-lang#12797
Along the lines of
shift_ref
andpop_ref
.