Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Add CI, apply rustfmt#10

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Manishearth merged 2 commits intomasterfromCI
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions.github/workflows/rustfmt.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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
21 changes: 21 additions & 0 deletions.github/workflows/tests.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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
7 changes: 7 additions & 0 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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/)
9 changes: 6 additions & 3 deletionssrc/general_security_profile.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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<IdentifierType> { identifier::identifier_type(self) }

fn identifier_type(self) -> Option<IdentifierType> {
identifier::identifier_type(self)
}
}
13 changes: 7 additions & 6 deletionssrc/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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" });
//! }
//! ```
Expand All@@ -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]

Expand All@@ -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;
Expand Down
19 changes: 11 additions & 8 deletionssrc/mixed_script.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,9 +23,10 @@ impl From<ScriptExtension> 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;
Expand All@@ -44,7 +45,9 @@ impl From<ScriptExtension> for AugmentedScriptSet {
}
Self {
base: ext,
hanb, jpan, kore
hanb,
jpan,
kore,
}
}
}
Expand DownExpand Up@@ -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;
Expand All@@ -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
Expand Down
7 changes: 3 additions & 4 deletionssrc/restriction_level.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand All@@ -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
Expand DownExpand Up@@ -72,4 +71,4 @@ impl RestrictionLevelDetection for &'_ str {
}
return RestrictionLevel::MinimallyRestrictive;
}
}
}

[8]ページ先頭

©2009-2025 Movatter.jp