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

Return Option rather than fail for slice_shift_char and {shift,pop}_{char,byte} #12797

Merged
merged 3 commits into from
Mar 12, 2014

Conversation

pczarn
Copy link
Contributor

@pczarn pczarn commented Mar 9, 2014

Along the lines of shift_ref and pop_ref.

@alexcrichton alexcrichton mentioned this pull request Mar 10, 2014
4 tasks
@@ -3600,6 +3612,22 @@ mod tests {
}

#[test]
fn test_slice_shift_char() {
let data = "ประเทศไทย中";
let (cc, rest) = data.slice_shift_char();
Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@alexcrichton
Copy link
Member

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());
Copy link
Member

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 unwraps you added to comparing against Some('...')? It makes test failures much easier to diagnose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

bors added a commit that referenced this pull request Mar 12, 2014
Along the lines of `shift_ref` and `pop_ref`.
@bors bors closed this Mar 12, 2014
@bors bors merged commit b0e855a into rust-lang:master Mar 12, 2014
lnicola pushed a commit to lnicola/rust that referenced this pull request Aug 9, 2022
…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
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.

4 participants