From 85ae6c0e759077e8df06cb5bb1715628cdbe4c3e Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 2 Jan 2020 08:52:24 +0530 Subject: [PATCH 1/2] Add CI, apply rustfmt --- .github/workflows/rustfmt.yml | 13 +++++++++++++ .github/workflows/tests.yml | 21 +++++++++++++++++++++ src/general_security_profile.rs | 9 ++++++--- src/lib.rs | 13 +++++++------ src/mixed_script.rs | 19 +++++++++++-------- src/restriction_level.rs | 7 +++---- 6 files changed, 61 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/rustfmt.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml new file mode 100644 index 0000000..c431880 --- /dev/null +++ b/.github/workflows/rustfmt.yml @@ -0,0 +1,13 @@ +name: Rustfmt + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Run rustfmt + run: cargo fmt -- --check diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..f97cfbd --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,21 @@ +name: Tests + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: beta + override: true + components: rustfmt + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test diff --git a/src/general_security_profile.rs b/src/general_security_profile.rs index 69200cf..7daeddd 100644 --- a/src/general_security_profile.rs +++ b/src/general_security_profile.rs @@ -16,8 +16,11 @@ pub trait GeneralSecurityProfile { impl GeneralSecurityProfile for char { #[inline] - fn identifier_allowed(self) -> bool { identifier::identifier_status_allowed(self) } + fn identifier_allowed(self) -> bool { + identifier::identifier_status_allowed(self) + } #[inline] - fn identifier_type(self) -> Option { identifier::identifier_type(self) } - + fn identifier_type(self) -> Option { + identifier::identifier_type(self) + } } diff --git a/src/lib.rs b/src/lib.rs index a358615..3ad4b80 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ //! let ch = 'µ'; // U+00B5 MICRO SIGN //! let allowed = 'µ'.identifier_allowed(); //! println!("{}", ch); -//! println!("The above char is {} in unicode identifiers.", +//! println!("The above char is {} in unicode identifiers.", //! if allowed { "allowed" } else { "restricted" }); //! } //! ``` @@ -42,9 +42,10 @@ //! ``` #![deny(missing_docs, unsafe_code)] -#![doc(html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png", - html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png")] - +#![doc( + html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png", + html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png" +)] #![cfg_attr(feature = "bench", feature(test))] #![no_std] @@ -57,12 +58,12 @@ extern crate test; pub use tables::UNICODE_VERSION; -pub mod mixed_script; pub mod general_security_profile; +pub mod mixed_script; pub mod restriction_level; -pub use mixed_script::MixedScript; pub use general_security_profile::GeneralSecurityProfile; +pub use mixed_script::MixedScript; #[rustfmt::skip] pub(crate) mod tables; diff --git a/src/mixed_script.rs b/src/mixed_script.rs index 7b4d55e..092c83a 100644 --- a/src/mixed_script.rs +++ b/src/mixed_script.rs @@ -23,9 +23,10 @@ impl From for AugmentedScriptSet { let mut jpan = false; let mut kore = false; - if ext == ScriptExtension::Single(Script::Common) || - ext == ScriptExtension::Single(Script::Inherited) || - ext.contains_script(Script::Han) { + if ext == ScriptExtension::Single(Script::Common) + || ext == ScriptExtension::Single(Script::Inherited) + || ext.contains_script(Script::Han) + { hanb = true; jpan = true; kore = true; @@ -44,7 +45,9 @@ impl From for AugmentedScriptSet { } Self { base: ext, - hanb, jpan, kore + hanb, + jpan, + kore, } } } @@ -74,7 +77,7 @@ impl Default for AugmentedScriptSet { impl AugmentedScriptSet { /// Intersect this set with another - pub fn intersect_with(&mut self, other: Self) { + pub fn intersect_with(&mut self, other: Self) { self.base.intersect_with(other.base); self.hanb = self.hanb && other.hanb; self.jpan = self.jpan && other.jpan; @@ -83,13 +86,13 @@ impl AugmentedScriptSet { /// Check if the set is empty pub fn is_empty(&self) -> bool { - self.base.is_empty() && ! self.hanb && !self.jpan && !self.kore + self.base.is_empty() && !self.hanb && !self.jpan && !self.kore } /// Check if the set is "All" (Common or Inherited) pub fn is_all(&self) -> bool { - self.base == ScriptExtension::Single(Script::Common) || - self.base == ScriptExtension::Single(Script::Inherited) + self.base == ScriptExtension::Single(Script::Common) + || self.base == ScriptExtension::Single(Script::Inherited) } /// Construct an AugmentedScriptSet for a given character diff --git a/src/restriction_level.rs b/src/restriction_level.rs index 05f5dd6..292a4fa 100644 --- a/src/restriction_level.rs +++ b/src/restriction_level.rs @@ -2,8 +2,8 @@ //! a string conforms to use crate::mixed_script::AugmentedScriptSet; -use unicode_script::{Script, ScriptExtension}; use crate::GeneralSecurityProfile; +use unicode_script::{Script, ScriptExtension}; #[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] /// The [Restriction level](https://www.unicode.org/reports/tr39/#Restriction_Level_Detection) @@ -24,14 +24,13 @@ pub enum RestrictionLevel { } /// Utilities for determining which [restriction level](https://www.unicode.org/reports/tr39/#Restriction_Level_Detection) -/// a string satisfies +/// a string satisfies pub trait RestrictionLevelDetection: Sized { /// Detect the [restriction level](https://www.unicode.org/reports/tr39/#Restriction_Level_Detection) /// /// This will _not_ check identifier well-formedness, as different applications may have different notions of well-formedness fn detect_restriction_level(self) -> RestrictionLevel; - /// Check if a string satisfies the supplied [restriction level](https://www.unicode.org/reports/tr39/#Restriction_Level_Detection) /// /// This will _not_ check identifier well-formedness, as different applications may have different notions of well-formedness @@ -72,4 +71,4 @@ impl RestrictionLevelDetection for &'_ str { } return RestrictionLevel::MinimallyRestrictive; } -} \ No newline at end of file +} From 4b833ba924ef37fa60fd65f9a4ffb3cd6aedd205 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 2 Jan 2020 08:54:25 +0530 Subject: [PATCH 2/2] Add readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index e69de29..22e8b6d 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,7 @@ +# unicode-security + +[![Build Status](https://github.com/unicode-rs/unicode-security/workflows/Tests/badge.svg)](https://github.com/unicode-rs/unicode-security/actions) +[![Current Version](https://meritbadge.herokuapp.com/unicode-security)](https://crates.io/crates/unicode-security) +[![License: MIT/Apache-2.0](https://img.shields.io/crates/l/unicode-security.svg)](#license) + +This crate exposes various utilities from [UAX #39 Unicode Security Mechanisms](https://www.unicode.org/reports/tr39/) \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy