Skip to content

Impl pretty-printing for AugmentedScriptSet #19

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

Merged
merged 2 commits into from
Jun 12, 2020

Conversation

crlf0710
Copy link
Collaborator

No description provided.

impl Debug for AugmentedScriptSet {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_empty() {
write!(f, "AugmentedScriptSet{{∅}}")?;
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a space after the name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure

let hanb = if self.hanb { Some("Hanb") } else { None };
let jpan = if self.jpan { Some("Jpan") } else { None };
let kore = if self.kore { Some("Kore") } else { None };
for writing_system in None.into_iter().chain(hanb).chain(jpan).chain(kore) {
Copy link
Member

Choose a reason for hiding this comment

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

we can just chain an base.iter.map(Script::short_name) here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed! Thanks

//for script in self.hanb
write!(f, "}}")?;
}
//if self.base.is_common() || self.base.is_
Copy link
Member

Choose a reason for hiding this comment

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

Remove the comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops

@@ -58,13 +58,21 @@ impl RestrictionLevelDetection for &'_ str {
}
}

fn single_item<I: Iterator>(mut iter: I) -> Option<I::Item> {
Copy link
Member

Choose a reason for hiding this comment

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

Can we instead implement this via count_ones()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean accessing the bitset underlying ScriptExtension directly? We cannot access the implementation detail from this crate...

Copy link
Member

Choose a reason for hiding this comment

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

Right, add that to the original crate. Maybe a len() method

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The PR is merged, now we need a new release of that crate.

Copy link
Member

Choose a reason for hiding this comment

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

Done.

@@ -67,14 +65,50 @@ impl From<&'_ str> for AugmentedScriptSet {
impl Default for AugmentedScriptSet {
fn default() -> Self {
AugmentedScriptSet {
base: ScriptExtension::Single(Script::Common),
base: ScriptExtension::from(Script::Common),
Copy link
Member

Choose a reason for hiding this comment

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

nit: I prefer .into()

@crlf0710
Copy link
Collaborator Author

Rebased and addressed the review comments.

@Manishearth Manishearth merged commit 1d0a740 into unicode-rs:master Jun 12, 2020
@crlf0710 crlf0710 deleted the impl_debug branch June 12, 2020 16:06
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