diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-14 17:49:18 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-14 17:49:18 +0000 |
commit | 6a5100f4d51ccf782f68e1a11083be38e3b8c96d (patch) | |
tree | 293c1166513fa5c21f7f359dc65093ff376277e9 /crates/ra_assists/src/lib.rs | |
parent | e406f2bed66cbe13ef6441a3fb84791a3ca09299 (diff) | |
parent | 60251da204e9b814a2947895851dfc78539e92f3 (diff) |
Merge #2834
2834: refactor(ra_syntax.validation): removed code duplication from validate_literal() r=kiljacken a=Veetaha
Hi! This is my first ever contribution to this project.
I've taken some dirty job from issue #223
This is a simple atomic PR to remove code duplication according to FIXME comment in the function that is the main focus of the further development.
I just didn't want to mix refactoring with the implementation of new features...
I am not sure whether you prefer such atomic PRs here or you'd rather have a single PR that contains all atomic commits inside of it?
So if you want me to add all that validation in one PR I'll mark this one as WIP and update it when the work is finished, otherwise, I'll go with the option of creating separate PRs per each feature of validation of strings, numbers, and comments respectively.
### Comments about refactoring
Yeah, reducing the duplication is quite hard here, extracting into stateless functions could be another option but the number of their arguments would be very big and repeated across char and string implementations so that just writing their types and names would become cumbersome.
I tried the option of having everything captured implicitly in the closure but failed since rust doesn't have templated (or generic) closures as C++ does, this is needed because `unescape_byte*()` and `unescape_char|str()` have different return types...
Maybe I am missing something here? I may be wrong because I am not enough experienced in Rust...
Well, I am awaiting any kind of feedback!
Co-authored-by: Veetaha <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/lib.rs')
0 files changed, 0 insertions, 0 deletions