8000 Add CI, apply rustfmt · unicode-rs/unicode-security@85ae6c0 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 85ae6c0

Browse files
committed
Add CI, apply rustfmt
1 parent dca4718 commit 85ae6c0

File tree

6 files changed

+61
-21
lines changed

6 files changed

+61
-21
lines changed

.github/workflows/rustfmt.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Rustfmt
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v1
12+
- name: Run rustfmt
13+
run: cargo fmt -- --check

.github/workflows/tests.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Tests
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v1
12+
- uses: actions-rs/toolchain@v1
13+
with:
14+
profile: minimal
15+
toolchain: beta
16+
override: true
17+
components: rustfmt
18+
- name: Build
19+
run: cargo build --verbose
20+
- name: Run tests
21+
run: cargo test

src/general_security_profile.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ pub trait GeneralSecurityProfile {
1616

1717
impl GeneralSecurityProfile for char {
1818
#[inline]
19-
fn identifier_allowed(self) -> bool { identifier::identifier_status_allowed(self) }
19+
fn identifier_allowed(self) -> bool {
20+
identifier::identifier_status_allowed(self)
21+
}
2022
#[inline]
21-
fn identifier_type(self) -> Option<IdentifierType> { identifier::identifier_type(self) }
22-
23+
fn identifier_type(self) -> Option<IdentifierType> {
24+
identifier::identifier_type(self)
25+
}
2326
}

src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//! let ch = 'µ'; // U+00B5 MICRO SIGN
2222
//! let allowed = 'µ'.identifier_allowed();
2323
//! println!("{}", ch);
24-
//! println!("The above char is {} in unicode identifiers.",
24+
//! println!("The above char is {} in unicode identifiers.",
2525
//! if allowed { "allowed" } else { "restricted" });
2626
//! }
2727
//! ```
@@ -42,9 +42,10 @@
4242
//! ```
4343
4444
#![deny(missing_docs, unsafe_code)]
45-
#![doc(html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png",
46-
html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png")]
47-
45+
#![doc(
46+
html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png",
47+
html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png"
48+
)]
4849
#![cfg_attr(feature = "bench", feature(test))]
4950
#![no_std]
5051

@@ -57,12 +58,12 @@ extern crate test;
5758

5859
pub use tables::UNICODE_VERSION;
5960

60-
pub mod mixed_script;
6161
pub mod general_security_profile;
62+
pub mod mixed_script;
6263
p 57AE ub mod restriction_level;
6364

64-
pub use mixed_script::MixedScript;
6565
pub use general_security_profile::GeneralSecurityProfile;
66+
pub use mixed_script::MixedScript;
6667

6768
#[rustfmt::skip]
6869
pub(crate) mod tables;

src/mixed_script.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ impl From<ScriptExtension> for AugmentedScriptSet {
2323
let mut jpan = false;
2424
let mut kore = false;
2525

26-
if ext == ScriptExtension::Single(Script::Common) ||
27-
ext == ScriptExtension::Single(Script::Inherited) ||
28-
ext.contains_script(Script::Han) {
26+
if ext == ScriptExtension::Single(Script::Common)
27+
|| ext == ScriptExtension::Single(Script::Inherited)
28+
|| ext.contains_script(Script::Han)
29+
{
2930
hanb = true;
3031
jpan = true;
3132
kore = true;
@@ -44,7 +45,9 @@ impl From<ScriptExtension> for AugmentedScriptSet {
4445
}
4546
Self {
4647
base: ext,
47-
hanb, jpan, kore
48+
hanb,
49+
jpan,
50+
kore,
4851
}
4952
}
5053
}
@@ -74,7 +77,7 @@ impl Default for AugmentedScriptSet {
7477

7578
impl AugmentedScriptSet {
7679
/// Intersect this set with another
77-
pub fn intersect_with(&mut self, other: Self) {
80+
pub fn intersect_with(&mut self, other: Self) {
7881
self.base.intersect_with(other.base);
7982
self.hanb = self.hanb && other.hanb;
8083
self.jpan = self.jpan && other.jpan;
@@ -83,13 +86,13 @@ impl AugmentedScriptSet {
8386

8487
/// Check if the set is empty
8588
pub fn is_empty(&self) -> bool {
86-
self.base.is_empty() && ! self.hanb && !self.jpan && !self.kore
89+
self.base.is_empty() && !self.hanb && !self.jpan && !self.kore
8790
}
8891

8992
/// Check if the set is "All" (Common or Inherited)
9093
pub fn is_all(&self) -> bool {
91-
self.base == ScriptExtension::Single(Script::Common) ||
92-
self.base == ScriptExtension::Single(Script::Inherited)
94+
self.base == ScriptExtension::Single(Script::Common)
95+
|| self.base == ScriptExtension::Single(Script::Inherited)
9396
}
9497

9598
/// Construct an AugmentedScriptSet for a given character

src/restriction_level.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//! a string conforms to
33
44
use crate::mixed_script::AugmentedScriptSet;
5-
use unicode_script::{Script, ScriptExtension};
65
use crate::GeneralSecurityProfile;
6+
use unicode_script::{Script, ScriptExtension};
77

88
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
99
/// The [Restriction level](https://www.unicode.org/reports/tr39/#Restriction_Level_Detection)
@@ -24,14 +24,13 @@ pub enum RestrictionLevel {
2424
}
2525

2626
/// Utilities for determining which [restriction level](https://www.unicode.org/reports/tr39/#Restriction_Level_Detection)
27-
/// a string satisfies
27+
/// a string satisfies
2828
pub trait RestrictionLevelDetection: Sized {
2929
/// Detect the [restriction level](https://www.unicode.org/reports/tr39/#Restriction_Level_Detection)
3030
///
3131
/// This will _not_ check identifier well-formedness, as different applications may have different notions of well-formedness
3232
fn detect_restriction_level(self) -> RestrictionLevel;
3333

34-
3534
/// Check if a string satisfies the supplied [restriction level](https://www.unicode.org/reports/tr39/#Restriction_Level_Detection)
3635
///
3736
/// 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 {
7271
}
7372
return RestrictionLevel::MinimallyRestrictive;
7473
}
75-
}
74+
}

0 commit comments

Comments
 (0)
0