GithubHelp home page GithubHelp logo

unicase's Introduction

unicase

crates.io Released API docs MIT licensed CI

Compare strings when case is not important (using Unicode Case-folding).

// ignore ASCII case
let a = UniCase::new("foobar");
let b = UniCase::new("FOOBAR");

assert_eq!(a, b);

// using unicode case-folding
let c = UniCase::new("Maße")
let d = UniCase::new("MASSE");
assert_eq!(c, d);

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

unicase's People

Contributors

abonander avatar cryze avatar cuviper avatar flada-auxv avatar frewsxcv avatar nox avatar paolobarbolini avatar peterreid avatar reem avatar retep998 avatar ryman avatar seanmonstar avatar sergiobenitez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unicase's Issues

Implement Pattern

Is it possible to have Ascii/UniCase implement std::str::pattern::Pattern?

This requires the nightly pattern feature, but can be gated with an optional feature.

New version fails compiling on nightly after 1.31

Hi,
The above 1.31 rustc rules you did doesn't work with nightly.
I'm using rustc 1.31.0-nightly (fc403ad98 2018-09-30) and all my builds broke this morning with this Error:

error[E0658]: const fn is unstable (see issue #53555)                      
  --> /home/elichai2/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-2.3.0/src/ascii.rs:15:5
   |                                                                       
15 | /     pub const fn new(s: S) -> Ascii<S> {                                 
16 | |         Ascii(s)                                                   
17 | |     }                                                                                                                                            
   | |_____^                                                               
   |                                                                                                                                                    
   = help: add #![feature(min_const_fn)] to the crate attributes to enable             
                                                                                                                                                      
error[E0658]: const fn is unstable (see issue #53555)                                    
   --> /home/elichai2/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-2.3.0/src/lib.rs:134:5                                                    
    |                                                                    
134 | /     pub const fn unicode(s: S) -> UniCase<S> {                                                                                                   
135 | |         UniCase(Encoding::Unicode(Unicode(s)))                   
136 | |     }                                                                                                                                            
    | |_____^                                                             
    |                                                                                                                                                 
    = help: add #![feature(min_const_fn)] to the crate attributes to enable

I fixed this for now by pinning unicase to 2.2.0 in my main toml file.

Mismatch return types

/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:82:5: 84:6 error: method from_str has an incompatible type for trait: expected enum core::result::Result, found enum core::option::Option [E0053]
/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:82 fn from_str(s: &str) -> Option<UniCase> {
/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:83 s.parse().map(UniCase)
/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:84 }
/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:81:1: 85:2 error: not all trait items implemented, missing: Err [E0046]
/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:81 impl<S: FromStr> FromStr for UniCase {
/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:82 fn from_str(s: &str) -> Option<UniCase> {
/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:83 s.parse().map(UniCase)
/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:84 }
/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:85 }
Build failed, waiting for other jobs to finish...
/home/dedrain/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.3/src/lib.rs:83:9: 83:31 error: mismatched types:
expected core::option::Option<UniCase<S>>,
found core::result::Result<UniCase<_>, _>
(expected enum core::option::Option,
found enum core::result::Result) [E0308]

Rust Version:
rustc 1.0.0-nightly (eaf4c5c78 2015-02-02 15:04:54 +0000)

Unable to build "unicase" with rustc 1.45.0 (5c1f21c3b 2020-07-13)

After updating rustc to version 1.45.0, and rebuilding my project with cargo build the build process fails, below the details related:

Logs

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/Users/.rustup/...

...

error: aborting due to previous error

error: could not compile `unicase`.

Cargo.toml

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.8"
reqwest = "0.10"
tiny_http = "0.6"
tokio = { version = "0.2", features = ["full"] }

Nonexistent trait `hash::Writer` on latest nightly

rustc version: rustc 1.0.0-nightly (522d09dfe 2015-02-19) (built 2015-02-20)
cargo build output:

     Running `rustc /root/.cargo/registry/src/github.com-1ecc6299db9ec823/mime-0.0.8/src/lib.rs --crate-name mime --crate-type lib -g -C metadata=07d69fef5f5ebf5d -C extra-filename=-07d69fef5f5ebf5d --out-dir /home/yo/work/extra/target/deps --emit=dep-info,link -L dependency=/home/yo/work/extra/target/deps -L dependency=/home/yo/work/extra/target/deps --extern log=/home/yo/work/extra/target/deps/liblog-7598d7f2dd99576c.rlib -Awarnings`
/root/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.4/src/lib.rs:84:9: 84:21 error: attempt to bound type parameter with a nonexistent trait `hash::Writer`
/root/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-0.0.4/src/lib.rs:84 impl<H: hash::Writer + hash::Hasher, S: Deref<Target=str>> hash::Hash<H> for UniCase<S> {

Creating a case-insensitive HashMap

Hi, this is more of a query/check my understanding thing than an issue per se.

I have quite often wanted to create a HashMap that uses strings as its keys, but compares them case-insensitively. I've now done this (code is not yet on crates.io) but I'm not exactly overjoyed with the code as it requires using Unicase objects for all the keys. Still, it works.

In comparison, to create such a map in C# you can simply do

var ciDict = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

This works without allocating any new objects, it just does all hashing and equality comparisons in a case-insensitive manner.

I was wondering about achieving the same in Rust, and I thought it might be possible if the hash algorithm from Unicase was usable externally so that it could be passed as the hash algorithm for a HashMap. But then I realised you also need to have the HashMap use case-insensitive equality comparisons (to deal with the case when hashes collide) and while a HashMap can be parameterized over its hash function, there is no way to parameterize it over its equality function as well.

Anyway, thanks for Unicase, I just wondered if you had ever thought about this use-case. I'm thinking of publishing my CiHashMap on crates.io, even if it's not great it is at least usable.

Consider removing version_check

This crate currently uses version_check to support Rust versions older than 1.36.0. This is ancient history by Rust's standards, so perhaps it is worth it to remove build.rs and version_check altogether. The motivation being compilation-time performance --- one less deb and one less build.rs would shave off some milliseconds. Not a huge win, of course, but still a meaningful reduction, given crate's popularity.

Enum privacy solution

unicase/src/unicode/mod.rs

Lines 96 to 105 in 7b116bc

// internal mod so that the enum can be 'pub'
// thanks privacy-checker :___(
mod fold {
#[derive(Clone, Copy)]
pub enum Fold {
Zero,
One(char),
Two(char, char),
Three(char, char, char),
}

Would this achieve the same thing?

pub(self) enum Fold { 
    Zero, 
    One(char), 
    Two(char, char), 
    Three(char, char, char), 
}

Reducing the size on WASM targets

On WASM targets, this library's unicode lookup table adds roughly 50 KB to release builds.
This makes it the second biggest contributor to my binary size right now, right behind the data section.

I would like to write a PR that on WASM targets uses js-sys's toLowerCase instead of the lookup table. This may result in different behavior between WASM and other targets though.

Would a PR like this be accepted? Would it need to be behind a feature gate?

Character iterator comparison

i need to compare (without regard for the case) two strings that are not UTF-8 encoded. The only access I have to the individual chars is through an iterator.

Would it be possible for this crate to expose a comparison interface between two char iterators? Something like:

/// Check the equality of two character iterators.
fn stream_eq<A: Iterator<Item=char>, B: Iterator<Item=char>>(a: A, b: B) -> bool;

/// Compare two character iterators.
fn stream_cmp<A: Iterator<Item=char>, B: Iterator<Item=char>>(a: A, b: B) -> cmp::Ordering;

Add debugger visualization support

Rust 1.71 was just released, adding support for #[debugger_visualizer] attribute for all types.

This crate imposes multiple level nesting in the current debuggers and should take advantage of natviz support available now.

Security Advisory on unicase > 2.0.0 && < 2.6.0

Hi @seanmonstar as part of this:
#38 - Incorrect results for substrings of ascii text

There was a proposal for an security advisory here:
rustsec/advisory-db#1176

Would you like us to flag an advisory on the old versions or would you prefer to yank the older versions as this may have implications on things that rely on this library especially when this behaviour was undefined / undocumented ?

Considering this can be used to critically compare strings and may result to downstream vulnerabilities as outlined in the proposal.

Cheers

build script error parsing rustc -vV on macOS

error: failed to run custom build command for `unicase v1.1.1`
process didn't exit successfully: `/Users/kking/ws/rws/iron/target/debug/build/unicase-1805bbf0a2de2eea/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'unexpected -vV format', /Users/kking/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc_version-0.1.4/src/lib.rs:115:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

It looks like the parsing code is expecting 6 lines but my output includes 7.

$ rustc -vV
rustc 1.29.1 (b801ae664 2018-09-20)
binary: rustc
commit-hash: b801ae66425cf7c3c71052b19ef8f145b0d0513d
commit-date: 2018-09-20
host: x86_64-apple-darwin
release: 1.29.1
LLVM version: 7.0

unexpected_cfgs warnings with 1.80

warning: unexpected `cfg` condition name: `__unicase__core_and_alloc`
 --> src/lib.rs:5:17
  |
5 | #![cfg_attr(all(__unicase__core_and_alloc, not(test),), no_std)]
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
  = help: consider using a Cargo feature instead
  = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
           [lints.rust]
           unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__core_and_alloc)'] }
  = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__core_and_alloc)");` to the top of the `build.rs`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition name: `__unicase__core_and_alloc`
  --> src/lib.rs:49:11
   |
49 | #[cfg(all(__unicase__core_and_alloc, not(test)))]
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__core_and_alloc)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__core_and_alloc)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__core_and_alloc`
  --> src/lib.rs:51:11
   |
51 | #[cfg(all(__unicase__core_and_alloc, not(test)))]
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__core_and_alloc)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__core_and_alloc)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__core_and_alloc`
  --> src/lib.rs:54:15
   |
54 | #[cfg(not(all(__unicase__core_and_alloc, not(test))))]
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__core_and_alloc)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__core_and_alloc)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__core_and_alloc`
  --> src/lib.rs:56:15
   |
56 | #[cfg(not(all(__unicase__core_and_alloc, not(test))))]
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__core_and_alloc)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__core_and_alloc)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__iter_cmp`
  --> src/lib.rs:60:7
   |
60 | #[cfg(__unicase__iter_cmp)]
   |       ^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__iter_cmp)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__iter_cmp)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__iter_cmp`
   --> src/lib.rs:311:7
    |
311 | #[cfg(__unicase__iter_cmp)]
    |       ^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using a Cargo feature instead
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__iter_cmp)'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__iter_cmp)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__iter_cmp`
   --> src/lib.rs:319:7
    |
319 | #[cfg(__unicase__iter_cmp)]
    |       ^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using a Cargo feature instead
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__iter_cmp)'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__iter_cmp)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__iter_cmp`
 --> src/ascii.rs:2:7
  |
2 | #[cfg(__unicase__iter_cmp)]
  |       ^^^^^^^^^^^^^^^^^^^
  |
  = help: consider using a Cargo feature instead
  = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
           [lints.rust]
           unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__iter_cmp)'] }
  = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__iter_cmp)");` to the top of the `build.rs`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__core_and_alloc`
 --> src/ascii.rs:8:11
  |
8 | #[cfg(not(__unicase__core_and_alloc))]
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: consider using a Cargo feature instead
  = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
           [lints.rust]
           unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__core_and_alloc)'] }
  = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__core_and_alloc)");` to the top of the `build.rs`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__iter_cmp`
  --> src/ascii.rs:61:7
   |
61 | #[cfg(__unicase__iter_cmp)]
   |       ^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__iter_cmp)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__iter_cmp)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__iter_cmp`
  --> src/ascii.rs:69:7
   |
69 | #[cfg(__unicase__iter_cmp)]
   |       ^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__iter_cmp)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__iter_cmp)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__const_fns`
  --> src/ascii.rs:16:11
   |
16 |     #[cfg(__unicase__const_fns)]
   |           ^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__const_fns)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__const_fns)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__const_fns`
  --> src/ascii.rs:25:15
   |
25 |     #[cfg(not(__unicase__const_fns))]
   |               ^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__const_fns)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__const_fns)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase_const_fns`
  --> src/ascii.rs:30:11
   |
30 |     #[cfg(__unicase_const_fns)]
   |           ^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase_const_fns)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase_const_fns)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase_const_fns`
  --> src/ascii.rs:35:15
   |
35 |     #[cfg(not(__unicase_const_fns))]
   |               ^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase_const_fns)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase_const_fns)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__core_and_alloc`
 --> src/unicode/mod.rs:1:11
  |
1 | #[cfg(all(__unicase__core_and_alloc, not(test)))]
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: consider using a Cargo feature instead
  = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
           [lints.rust]
           unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__core_and_alloc)'] }
  = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__core_and_alloc)");` to the top of the `build.rs`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__iter_cmp`
 --> src/unicode/mod.rs:3:7
  |
3 | #[cfg(__unicase__iter_cmp)]
  |       ^^^^^^^^^^^^^^^^^^^
  |
  = help: consider using a Cargo feature instead
  = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
           [lints.rust]
           unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__iter_cmp)'] }
  = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__iter_cmp)");` to the top of the `build.rs`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__iter_cmp`
  --> src/unicode/mod.rs:46:7
   |
46 | #[cfg(__unicase__iter_cmp)]
   |       ^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__iter_cmp)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__iter_cmp)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__iter_cmp`
  --> src/unicode/mod.rs:54:7
   |
54 | #[cfg(__unicase__iter_cmp)]
   |       ^^^^^^^^^^^^^^^^^^^
   |
   = help: consider using a Cargo feature instead
   = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
            [lints.rust]
            unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__iter_cmp)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__iter_cmp)");` to the top of the `build.rs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__core_and_alloc`
   --> src/lib.rs:131:19
    |
131 |         #[cfg(not(__unicase__core_and_alloc))]
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using a Cargo feature instead
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__core_and_alloc)'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__core_and_alloc)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__core_and_alloc`
   --> src/lib.rs:150:19
    |
150 |         #[cfg(not(__unicase__core_and_alloc))]
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using a Cargo feature instead
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__core_and_alloc)'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__core_and_alloc)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__const_fns`
   --> src/lib.rs:163:11
    |
163 |     #[cfg(__unicase__const_fns)]
    |           ^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using a Cargo feature instead
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__const_fns)'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__const_fns)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__const_fns`
   --> src/lib.rs:171:15
    |
171 |     #[cfg(not(__unicase__const_fns))]
    |               ^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using a Cargo feature instead
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__const_fns)'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__const_fns)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__const_fns`
   --> src/lib.rs:177:11
    |
177 |     #[cfg(__unicase__const_fns)]
    |           ^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using a Cargo feature instead
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__const_fns)'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__const_fns)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition name: `__unicase__const_fns`
   --> src/lib.rs:185:15
    |
185 |     #[cfg(not(__unicase__const_fns))]
    |               ^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using a Cargo feature instead
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(__unicase__const_fns)'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(__unicase__const_fns)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: `unicase` (lib) generated 26 warnings

Use transparent representation to allow casts

A repr(transparent) annotation would allow users to (soundly) cast pointers to Ts to UniCase<T>s. This is handy when you can't trivially dereference the pointer, which can come up in generic code.

  • Also mentioned here: #22 (comment)
  • This should be a fairly trivial change. LMK if you want a PR 😃

Relicense under dual MIT/Apache-2.0

This issue was automatically generated. Feel free to close without ceremony if
you do not agree with re-licensing or if it is not possible for other reasons.
Respond to @cmr with any questions or concerns, or pop over to
#rust-offtopic on IRC to discuss.

You're receiving this because someone (perhaps the project maintainer)
published a crates.io package with the license as "MIT" xor "Apache-2.0" and
the repository field pointing here.

TL;DR the Rust ecosystem is largely Apache-2.0. Being available under that
license is good for interoperation. The MIT license as an add-on can be nice
for GPLv2 projects to use your code.

Why?

The MIT license requires reproducing countless copies of the same copyright
header with different names in the copyright field, for every MIT library in
use. The Apache license does not have this drawback. However, this is not the
primary motivation for me creating these issues. The Apache license also has
protections from patent trolls and an explicit contribution licensing clause.
However, the Apache license is incompatible with GPLv2. This is why Rust is
dual-licensed as MIT/Apache (the "primary" license being Apache, MIT only for
GPLv2 compat), and doing so would be wise for this project. This also makes
this crate suitable for inclusion and unrestricted sharing in the Rust
standard distribution and other projects using dual MIT/Apache, such as my
personal ulterior motive, the Robigalia project.

Some ask, "Does this really apply to binary redistributions? Does MIT really
require reproducing the whole thing?" I'm not a lawyer, and I can't give legal
advice, but some Google Android apps include open source attributions using
this interpretation. Others also agree with
it
.
But, again, the copyright notice redistribution is not the primary motivation
for the dual-licensing. It's stronger protections to licensees and better
interoperation with the wider Rust ecosystem.

How?

To do this, get explicit approval from each contributor of copyrightable work
(as not all contributions qualify for copyright, due to not being a "creative
work", e.g. a typo fix) and then add the following to your README:

## License

Licensed under either of

 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.

and in your license headers, if you have them, use the following boilerplate
(based on that used in Rust):

// Copyright 2016 unicase Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

It's commonly asked whether license headers are required. I'm not comfortable
making an official recommendation either way, but the Apache license
recommends it in their appendix on how to use the license.

Be sure to add the relevant LICENSE-{MIT,APACHE} files. You can copy these
from the Rust repo for a plain-text
version.

And don't forget to update the license metadata in your Cargo.toml to:

license = "MIT OR Apache-2.0"

I'll be going through projects which agree to be relicensed and have approval
by the necessary contributors and doing this changes, so feel free to leave
the heavy lifting to me!

Contributor checkoff

To agree to relicensing, comment with :

I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to chose either at their option.

Or, if you're a contributor, you can check the box in this repo next to your
name. My scripts will pick this exact phrase up and check your checkbox, but
I'll come through and manually review this issue later as well.

Caseless comparisons not implemented correctly? (Normalization of precomposed / non-composed Unicode text missing)

Hi,

I stumbled upon this StackOverflow question, where BurntSushi5 (I guess this is @BurntSushi) wrote the following in a comment that proposed UniCase:

I don't think that crate implements correct caseless comparisons because I don't see any normalization happening. The caseless crate does it correctly (but has a different API, so there might be some trade offs between them): docs.rs/caseless/0.2.0/caseless

Shepmaster provided an example that demonstrates the problem:

assert_eq!(UniCase::new("Åström"), UniCase::new("Åström")

...which fails with:

thread 'test:tests::unicase' panicked at 'assertion failed: `(left == right)`
  left: `"Åström"`,
 right: `"A\u{30a}stro\u{308}m"`', test/src/test.rs:112:5

I didn't find an existing issue, so I thought I'll just open one.

unicase no longer builds on stable/beta

Currently errors out with:

   Compiling unicase v1.1.0
.../unicase-1.1.0/src/lib.rs:55:20: 55:36 error: use of unstable library feature 'iter_order': needs review and revision (see issue #27737)
.../unicase-1.1.0/src/lib.rs:55         self_chars.cmp(other_chars)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.