Skip to content

Commit 06949e7

Browse files
committed
fix clippy warnings
1 parent a05043b commit 06949e7

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

scripts/unicode.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,7 @@ def emit_general_category_module(f):
275275
276276
#[inline]
277277
pub(crate) fn general_category_of_char(c: char) -> GeneralCategory {
278-
match c as usize {
279-
_ => super::util::bsearch_range_value_table(c, GENERAL_CATEGORY).unwrap_or(GeneralCategory::Unassigned)
280-
}
278+
super::util::bsearch_range_value_table(c, GENERAL_CATEGORY).unwrap_or(GeneralCategory::Unassigned)
281279
}
282280
283281
#[inline]
@@ -369,7 +367,7 @@ def emit_general_category_module(f):
369367
general_category_char_table[input_idx][1], general_category_group_table[existing_group_count - 1][2])
370368
else:
371369
general_category_group_table.append(general_category_char_table[input_idx])
372-
emit_table(f, "GENERAL_CATEGORY", general_category_group_table, "&'static [(char, char, GeneralCategory)]", is_pub=False,
370+
emit_table(f, "GENERAL_CATEGORY", general_category_group_table, "&[(char, char, GeneralCategory)]", is_pub=False,
373371
pfun=lambda x: "(%s,%s,%s)" % (escape_char(x[0]), escape_char(x[1]), gc_variants[x[2]]))
374372
f.write("}\n\n")
375373

@@ -405,9 +403,7 @@ def emit_emoji_module(f):
405403
#[inline]
406404
pub(crate) fn emoji_status(c: char) -> EmojiStatus {
407405
// FIXME: do we want to special case ASCII here?
408-
match c as usize {
409-
_ => super::util::bsearch_range_value_table(c, EMOJI_STATUS).unwrap()
410-
}
406+
super::util::bsearch_range_value_table(c, EMOJI_STATUS).unwrap()
411407
}
412408
#[inline]
413409
pub(crate) fn is_emoji_status_for_emoji_char_or_emoji_component(s: EmojiStatus) -> bool {
@@ -491,7 +487,7 @@ def group_text(s):
491487
emoji_prop_list_pos[prop_list_idx] += 1
492488
cur_group_first = cur_group_last + 1
493489

494-
emit_table(f, "EMOJI_STATUS", emoji_table, "&'static [(char, char, EmojiStatus)]", is_pub=False,
490+
emit_table(f, "EMOJI_STATUS", emoji_table, "&[(char, char, EmojiStatus)]", is_pub=False,
495491
pfun=lambda x: "(%s,%s,%s)" % (escape_char(x[0]), escape_char(x[1]), x[2]))
496492
f.write("}\n\n")
497493

src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
//! use unicode_properties::UnicodeEmoji;
2222
//! use unicode_properties::UnicodeGeneralCategory;
2323
//!
24-
//! fn main() {
25-
//! let ch = '🦀'; // U+1F980 CRAB
26-
//! let is_emoji = ch.is_emoji_char();
27-
//! let group = ch.general_category_group();
28-
//! println!("{}({:?})", ch, group);
29-
//! println!("The above char {} for use as emoji char.",
30-
//! if is_emoji { "is recommended" } else { "is not recommended" });
31-
//! }
24+
//! let ch = '🦀'; // U+1F980 CRAB
25+
//! let is_emoji = ch.is_emoji_char();
26+
//! let group = ch.general_category_group();
27+
//! println!("{}({:?})", ch, group);
28+
//! println!("The above char {} for use as emoji char.",
29+
//! if is_emoji { "is recommended" } else { "is not recommended" });
3230
//! ```
3331
//!
3432
//! # Features
@@ -59,17 +57,20 @@ pub mod emoji {
5957
fn emoji_status(self) -> EmojiStatus;
6058

6159
/// Checks whether this character is recommended for use as emoji, i.e. `Emoji=YES`.
60+
#[allow(clippy::wrong_self_convention)]
6261
fn is_emoji_char(self) -> bool {
6362
crate::tables::emoji::is_emoji_status_for_emoji_char(self.emoji_status())
6463
}
6564

6665
/// Checks whether this character are used in emoji sequences where they're not
6766
/// intended for independent, direct input, i.e. `Emoji_Component=YES`.
67+
#[allow(clippy::wrong_self_convention)]
6868
fn is_emoji_component(self) -> bool {
6969
crate::tables::emoji::is_emoji_status_for_emoji_component(self.emoji_status())
7070
}
7171

7272
/// Checks whether this character occurs in emoji sequences, i.e. `Emoji=YES | Emoji_Component=YES`
73+
#[allow(clippy::wrong_self_convention)]
7374
fn is_emoji_char_or_emoji_component(self) -> bool {
7475
crate::tables::emoji::is_emoji_status_for_emoji_char_or_emoji_component(
7576
self.emoji_status(),
@@ -144,6 +145,7 @@ pub mod general_category {
144145
///
145146
/// The `LetterCased` group includes `LetterUppercase`, `LetterLowercase`, and `LetterTitlecase`
146147
/// categories, and is a subset of the `Letter` group.
148+
#[allow(clippy::wrong_self_convention)]
147149
fn is_letter_cased(self) -> bool {
148150
crate::tables::general_category::general_category_is_letter_cased(
149151
self.general_category(),

src/tables.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ pub mod general_category {
127127

128128
#[inline]
129129
pub(crate) fn general_category_of_char(c: char) -> GeneralCategory {
130-
match c as usize {
131-
_ => super::util::bsearch_range_value_table(c, GENERAL_CATEGORY).unwrap_or(GeneralCategory::Unassigned)
132-
}
130+
super::util::bsearch_range_value_table(c, GENERAL_CATEGORY).unwrap_or(GeneralCategory::Unassigned)
133131
}
134132

135133
#[inline]
@@ -173,7 +171,7 @@ pub mod general_category {
173171
}
174172
}
175173
// General category table:
176-
const GENERAL_CATEGORY: &'static [(char, char, GeneralCategory)] = &[
174+
const GENERAL_CATEGORY: &[(char, char, GeneralCategory)] = &[
177175
('\u{0}', '\u{1f}', GeneralCategory::Control), ('\u{20}', '\u{20}',
178176
GeneralCategory::SpaceSeparator), ('\u{21}', '\u{23}', GeneralCategory::OtherPunctuation),
179177
('\u{24}', '\u{24}', GeneralCategory::CurrencySymbol), ('\u{25}', '\u{27}',
@@ -2743,9 +2741,7 @@ pub mod emoji {
27432741
#[inline]
27442742
pub(crate) fn emoji_status(c: char) -> EmojiStatus {
27452743
// FIXME: do we want to special case ASCII here?
2746-
match c as usize {
2747-
_ => super::util::bsearch_range_value_table(c, EMOJI_STATUS).unwrap()
2748-
}
2744+
super::util::bsearch_range_value_table(c, EMOJI_STATUS).unwrap()
27492745
}
27502746
#[inline]
27512747
pub(crate) fn is_emoji_status_for_emoji_char_or_emoji_component(s: EmojiStatus) -> bool {
@@ -2762,7 +2758,7 @@ pub mod emoji {
27622758
EmojiStatus::EmojiOtherAndEmojiComponent)
27632759
}
27642760
// Emoji status table:
2765-
const EMOJI_STATUS: &'static [(char, char, EmojiStatus)] = &[
2761+
const EMOJI_STATUS: &[(char, char, EmojiStatus)] = &[
27662762
('\u{0}', '\u{22}', EmojiStatus::NonEmoji), ('\u{23}', '\u{23}',
27672763
EmojiStatus::EmojiOtherAndEmojiComponent), ('\u{24}', '\u{29}', EmojiStatus::NonEmoji),
27682764
('\u{2a}', '\u{2a}', EmojiStatus::EmojiOtherAndEmojiComponent), ('\u{2b}', '\u{2f}',

0 commit comments

Comments
 (0)