diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..4d414fe --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,75 @@ +name: Rust + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + RUSTFLAGS: -D warnings + RUSTDOCFLAGS: -D warnings --cfg docsrs + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + - beta + - nightly + steps: + - uses: actions/checkout@v2 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + components: rustfmt, clippy + - name: Build + run: cargo build --verbose + - name: Run tests with all features + run: cargo test --all-features --verbose + - name: Run tests without features + run: cargo test --lib --no-default-features --verbose + - name: Package + run: cargo package + - name: Test package + run: cd $(find target/package/ -maxdepth 1 -mindepth 1 -type d) && cargo test + - name: Test package without features + run: cd $(find target/package/ -maxdepth 1 -mindepth 1 -type d) && cargo test --lib --no-default-features + - name: Build docs + if: matrix.rust == 'nightly' + run: cargo doc --all-features --verbose + - name: Check formatting + if: matrix.rust == 'stable' + run: cargo fmt --all --check + - name: Check clippy + if: matrix.rust == 'stable' + run: cargo clippy --all-features --lib --tests --examples --verbose + - name: Check benchmarks with clippy + if: matrix.rust == 'nightly' + run: cargo clippy --all-features --benches --verbose + msrv: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install msrv toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.56 + override: true + - name: Build + run: cargo build --verbose --all-features + regen: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Regen + run: cd scripts && python3 unicode.py + - name: Diff tables + run: diff src/tables.rs scripts/tables.rs diff --git a/scripts/unicode.py b/scripts/unicode.py index d40c14c..8cb79c6 100644 --- a/scripts/unicode.py +++ b/scripts/unicode.py @@ -275,9 +275,7 @@ def emit_general_category_module(f): #[inline] pub(crate) fn general_category_of_char(c: char) -> GeneralCategory { - match c as usize { - _ => super::util::bsearch_range_value_table(c, GENERAL_CATEGORY).unwrap_or(GeneralCategory::Unassigned) - } + super::util::bsearch_range_value_table(c, GENERAL_CATEGORY).unwrap_or(GeneralCategory::Unassigned) } #[inline] @@ -369,7 +367,7 @@ def emit_general_category_module(f): general_category_char_table[input_idx][1], general_category_group_table[existing_group_count - 1][2]) else: general_category_group_table.append(general_category_char_table[input_idx]) - emit_table(f, "GENERAL_CATEGORY", general_category_group_table, "&'static [(char, char, GeneralCategory)]", is_pub=False, + emit_table(f, "GENERAL_CATEGORY", general_category_group_table, "&[(char, char, GeneralCategory)]", is_pub=False, pfun=lambda x: "(%s,%s,%s)" % (escape_char(x[0]), escape_char(x[1]), gc_variants[x[2]])) f.write("}\n\n") @@ -405,9 +403,7 @@ def emit_emoji_module(f): #[inline] pub(crate) fn emoji_status(c: char) -> EmojiStatus { // FIXME: do we want to special case ASCII here? - match c as usize { - _ => super::util::bsearch_range_value_table(c, EMOJI_STATUS).unwrap() - } + super::util::bsearch_range_value_table(c, EMOJI_STATUS).unwrap() } #[inline] pub(crate) fn is_emoji_status_for_emoji_char_or_emoji_component(s: EmojiStatus) -> bool { @@ -491,7 +487,7 @@ def group_text(s): emoji_prop_list_pos[prop_list_idx] += 1 cur_group_first = cur_group_last + 1 - emit_table(f, "EMOJI_STATUS", emoji_table, "&'static [(char, char, EmojiStatus)]", is_pub=False, + emit_table(f, "EMOJI_STATUS", emoji_table, "&[(char, char, EmojiStatus)]", is_pub=False, pfun=lambda x: "(%s,%s,%s)" % (escape_char(x[0]), escape_char(x[1]), x[2])) f.write("}\n\n") diff --git a/src/lib.rs b/src/lib.rs index 87849d1..a832734 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,14 +21,12 @@ //! use unicode_properties::UnicodeEmoji; //! use unicode_properties::UnicodeGeneralCategory; //! -//! fn main() { -//! let ch = '🦀'; // U+1F980 CRAB -//! let is_emoji = ch.is_emoji_char(); -//! let group = ch.general_category_group(); -//! println!("{}({:?})", ch, group); -//! println!("The above char {} for use as emoji char.", -//! if is_emoji { "is recommended" } else { "is not recommended" }); -//! } +//! let ch = '🦀'; // U+1F980 CRAB +//! let is_emoji = ch.is_emoji_char(); +//! let group = ch.general_category_group(); +//! println!("{}({:?})", ch, group); +//! println!("The above char {} for use as emoji char.", +//! if is_emoji { "is recommended" } else { "is not recommended" }); //! ``` //! //! # Features @@ -59,17 +57,20 @@ pub mod emoji { fn emoji_status(self) -> EmojiStatus; /// Checks whether this character is recommended for use as emoji, i.e. `Emoji=YES`. + #[allow(clippy::wrong_self_convention)] fn is_emoji_char(self) -> bool { crate::tables::emoji::is_emoji_status_for_emoji_char(self.emoji_status()) } /// Checks whether this character are used in emoji sequences where they're not /// intended for independent, direct input, i.e. `Emoji_Component=YES`. + #[allow(clippy::wrong_self_convention)] fn is_emoji_component(self) -> bool { crate::tables::emoji::is_emoji_status_for_emoji_component(self.emoji_status()) } /// Checks whether this character occurs in emoji sequences, i.e. `Emoji=YES | Emoji_Component=YES` + #[allow(clippy::wrong_self_convention)] fn is_emoji_char_or_emoji_component(self) -> bool { crate::tables::emoji::is_emoji_status_for_emoji_char_or_emoji_component( self.emoji_status(), @@ -144,6 +145,7 @@ pub mod general_category { /// /// The `LetterCased` group includes `LetterUppercase`, `LetterLowercase`, and `LetterTitlecase` /// categories, and is a subset of the `Letter` group. + #[allow(clippy::wrong_self_convention)] fn is_letter_cased(self) -> bool { crate::tables::general_category::general_category_is_letter_cased( self.general_category(), diff --git a/src/tables.rs b/src/tables.rs index 912ec85..a17228a 100644 --- a/src/tables.rs +++ b/src/tables.rs @@ -127,9 +127,7 @@ pub mod general_category { #[inline] pub(crate) fn general_category_of_char(c: char) -> GeneralCategory { - match c as usize { - _ => super::util::bsearch_range_value_table(c, GENERAL_CATEGORY).unwrap_or(GeneralCategory::Unassigned) - } + super::util::bsearch_range_value_table(c, GENERAL_CATEGORY).unwrap_or(GeneralCategory::Unassigned) } #[inline] @@ -173,7 +171,7 @@ pub mod general_category { } } // General category table: - const GENERAL_CATEGORY: &'static [(char, char, GeneralCategory)] = &[ + const GENERAL_CATEGORY: &[(char, char, GeneralCategory)] = &[ ('\u{0}', '\u{1f}', GeneralCategory::Control), ('\u{20}', '\u{20}', GeneralCategory::SpaceSeparator), ('\u{21}', '\u{23}', GeneralCategory::OtherPunctuation), ('\u{24}', '\u{24}', GeneralCategory::CurrencySymbol), ('\u{25}', '\u{27}', @@ -2743,9 +2741,7 @@ pub mod emoji { #[inline] pub(crate) fn emoji_status(c: char) -> EmojiStatus { // FIXME: do we want to special case ASCII here? - match c as usize { - _ => super::util::bsearch_range_value_table(c, EMOJI_STATUS).unwrap() - } + super::util::bsearch_range_value_table(c, EMOJI_STATUS).unwrap() } #[inline] pub(crate) fn is_emoji_status_for_emoji_char_or_emoji_component(s: EmojiStatus) -> bool { @@ -2762,7 +2758,7 @@ pub mod emoji { EmojiStatus::EmojiOtherAndEmojiComponent) } // Emoji status table: - const EMOJI_STATUS: &'static [(char, char, EmojiStatus)] = &[ + const EMOJI_STATUS: &[(char, char, EmojiStatus)] = &[ ('\u{0}', '\u{22}', EmojiStatus::NonEmoji), ('\u{23}', '\u{23}', EmojiStatus::EmojiOtherAndEmojiComponent), ('\u{24}', '\u{29}', EmojiStatus::NonEmoji), ('\u{2a}', '\u{2a}', EmojiStatus::EmojiOtherAndEmojiComponent), ('\u{2b}', '\u{2f}',
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: