Page MenuHomePhabricator

rust-utils: add `Escaped` trait
ClosedPublic

Authored by Alphare on Jan 14 2020, 12:33 PM.

Details

Summary

This will be used as a general interface for displaying things to the user.
The upcoming IncludeMatcher will use it to store its patterns in a
user-displayable string.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Alphare created this revision.Jan 14 2020, 12:33 PM
kevincox accepted this revision.Jan 15 2020, 10:16 AM

I'm not convinced PrettyPrint is the best name. I might call it something more to do with escaping instead of "pretty". However I can't think of anything great.

rust/hg-core/src/utils.rs
146
write!(acc, "\\x{:x}", self).unwrap();
Alphare retitled this revision from rust-utils: add `PrettyPrint` trait to rust-utils: add `Escaped` trait.Jan 15 2020, 4:56 PM
Alphare updated this revision to Diff 19320.

I'm not convinced PrettyPrint is the best name. I might call it something more to do with escaping instead of "pretty". However I can't think of anything great.

Yeah, I am not convinced either. I've sent a new patch, maybe that's better?

rust/hg-core/src/utils.rs
146

Oh nice!

Alphare updated this revision to Diff 19348.Jan 16 2020, 4:31 AM
kevincox accepted this revision.Jan 16 2020, 7:44 AM

I think it's better. Maybe still a little vauge but I'll let subject experts make that decision.

martinvonz requested changes to this revision.Feb 6 2020, 11:42 AM
martinvonz added a subscriber: martinvonz.

I'm also not sure about the name, but I don't have a better proposal. We can revisit that later when it's clearer how it will be used.

rust/hg-core/src/utils.rs
154–157

i.e. self.iter().flat_map(|item| item.escaped_bytes()).collect()?

This revision now requires changes to proceed.Feb 6 2020, 11:42 AM
Alphare added inline comments.Feb 6 2020, 11:45 AM
rust/hg-core/src/utils.rs
154–157

Sometimes I forget about flat_map. Thanks!

Alphare updated this revision to Diff 19958.Feb 6 2020, 11:47 AM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.