Import Upstream version 2.6.0

This commit is contained in:
denghao 2023-04-12 16:59:44 +08:00
commit f817ed46d4
24 changed files with 3400 additions and 0 deletions

5
.cargo_vcs_info.json Normal file
View File

@ -0,0 +1,5 @@
{
"git": {
"sha1": "7b116bc70c16b972a06c2e084ad1e9f3edfbaa2f"
}
}

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/scripts/CaseFolding.txt
/target
/Cargo.lock

31
.travis.yml Normal file
View File

@ -0,0 +1,31 @@
sudo: true
language: rust
matrix:
fast_finish: true
include:
- rust: nightly
env: FEATURES="--features nightly"
- rust: beta
- rust: stable
- rust: 1.3.0
# verify `const fn`
- rust: 1.31.0
# verify `no_std`
- rust: stable
script:
- rustup target add thumbv6m-none-eabi
- cargo build --target thumbv6m-none-eabi
cache:
apt: true
directories:
- target/debug/deps
- target/debug/build
script:
- cargo build --verbose $FEATURES
- cargo test --verbose $FEATURES
notifications:
email: false

30
Cargo.toml Normal file
View File

@ -0,0 +1,30 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[package]
name = "unicase"
version = "2.6.0"
authors = ["Sean McArthur <sean@seanmonstar.com>"]
build = "build.rs"
exclude = ["scripts/*"]
description = "A case-insensitive wrapper around strings."
documentation = "https://docs.rs/unicase"
readme = "README.md"
keywords = ["lowercase", "case", "case-insensitive", "case-folding", "no_std"]
categories = ["internationalization", "text-processing", "no-std"]
license = "MIT/Apache-2.0"
repository = "https://github.com/seanmonstar/unicase"
[build-dependencies.version_check]
version = "0.9"
[features]
nightly = []

24
Cargo.toml.orig Normal file
View File

@ -0,0 +1,24 @@
[package]
name = "unicase"
version = "2.6.0" # don't forget to update html_root_url
authors = ["Sean McArthur <sean@seanmonstar.com>"]
description = "A case-insensitive wrapper around strings."
repository = "https://github.com/seanmonstar/unicase"
documentation = "https://docs.rs/unicase"
license = "MIT/Apache-2.0"
readme = "README.md"
keywords = ["lowercase", "case", "case-insensitive", "case-folding", "no_std"]
categories = ["internationalization", "text-processing", "no-std"]
exclude = [
"scripts/*"
]
build = "build.rs"
[build-dependencies]
version_check = "0.9"
[features]
nightly = []

201
LICENSE-APACHE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

20
LICENSE-MIT Normal file
View File

@ -0,0 +1,20 @@
Copyright (c) 2014-2017 Sean McArthur
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

31
README.md Normal file
View File

@ -0,0 +1,31 @@
# unicase
[![Build Status](https://travis-ci.org/seanmonstar/unicase.svg?branch=master)](https://travis-ci.org/seanmonstar/unicase)
[Documentation](https://docs.rs/unicase)
Compare strings when case is not important (using Unicode Case-folding).
```rust
// 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
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
### 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.

23
build.rs Normal file
View File

@ -0,0 +1,23 @@
extern crate version_check as rustc;
fn main() {
if is_rustc_at_least("1.5.0") {
println!("cargo:rustc-cfg=__unicase__iter_cmp");
}
if is_rustc_at_least("1.13.0") {
println!("cargo:rustc-cfg=__unicase__default_hasher");
}
if is_rustc_at_least("1.31.0") {
println!("cargo:rustc-cfg=__unicase__const_fns");
}
if is_rustc_at_least("1.36.0") {
println!("cargo:rustc-cfg=__unicase__core_and_alloc");
}
}
fn is_rustc_at_least(v: &str) -> bool {
rustc::is_min_version(v).unwrap_or(true)
}

View File

@ -0,0 +1 @@
{"package":"50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6","files":{}}

26
debian-orig/changelog Normal file
View File

@ -0,0 +1,26 @@
rust-unicase (2.6.0-1) unstable; urgency=medium
* Team upload.
* Package unicase 2.6.0 from crates.io using debcargo 2.4.4-alpha.0
* Remove patches (applied upstream)
* Update needed by rust-ini
-- Sylvestre Ledru <sylvestre@debian.org> Tue, 22 Dec 2020 17:31:14 +0100
rust-unicase (2.5.1-1) unstable; urgency=medium
* Package unicase 2.5.1 from crates.io using debcargo 2.4.0
-- kpcyrd <git@rxv.cc> Mon, 28 Oct 2019 15:20:54 +0100
rust-unicase (2.4.0-1) unstable; urgency=medium
* Package unicase 2.4.0 from crates.io using debcargo 2.2.10
-- kpcyrd <git@rxv.cc> Sun, 14 Jul 2019 05:00:59 +0000
rust-unicase (2.1.0-1) unstable; urgency=medium
* Package unicase 2.1.0 from crates.io using debcargo 2.2.4
-- kpcyrd <git@rxv.cc> Tue, 31 Jul 2018 09:51:44 -0700

1
debian-orig/compat Normal file
View File

@ -0,0 +1 @@
12

38
debian-orig/control Normal file
View File

@ -0,0 +1,38 @@
Source: rust-unicase
Section: rust
Priority: optional
Build-Depends: debhelper (>= 12),
dh-cargo (>= 24),
cargo:native <!nocheck>,
rustc:native <!nocheck>,
libstd-rust-dev <!nocheck>,
librust-version-check-0.9+default-dev <!nocheck>
Maintainer: Debian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net>
Uploaders:
kpcyrd <git@rxv.cc>
Standards-Version: 4.5.1
Vcs-Git: https://salsa.debian.org/rust-team/debcargo-conf.git [src/unicase]
Vcs-Browser: https://salsa.debian.org/rust-team/debcargo-conf/tree/master/src/unicase
Rules-Requires-Root: no
Package: librust-unicase-dev
Architecture: any
Multi-Arch: same
Depends:
${misc:Depends},
librust-version-check-0.9+default-dev
Provides:
librust-unicase+default-dev (= ${binary:Version}),
librust-unicase+nightly-dev (= ${binary:Version}),
librust-unicase-2-dev (= ${binary:Version}),
librust-unicase-2+default-dev (= ${binary:Version}),
librust-unicase-2+nightly-dev (= ${binary:Version}),
librust-unicase-2.6-dev (= ${binary:Version}),
librust-unicase-2.6+default-dev (= ${binary:Version}),
librust-unicase-2.6+nightly-dev (= ${binary:Version}),
librust-unicase-2.6.0-dev (= ${binary:Version}),
librust-unicase-2.6.0+default-dev (= ${binary:Version}),
librust-unicase-2.6.0+nightly-dev (= ${binary:Version})
Description: Case-insensitive wrapper around strings - Rust source code
This package contains the source for the Rust unicase crate, packaged by
debcargo for use with cargo and dh-cargo.

37
debian-orig/copyright Normal file
View File

@ -0,0 +1,37 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: unicase
Upstream-Contact: Sean McArthur <sean@seanmonstar.com>
Source: https://github.com/seanmonstar/unicase
Files: *
Copyright: 2014-2019 Sean McArthur <sean@seanmonstar.com>
License: MIT or Apache-2.0
Files: debian/*
Copyright:
2018-2019 Debian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net>
2018-2019 kpcyrd <git@rxv.cc>
License: MIT or Apache-2.0
License: Apache-2.0
Debian systems provide the Apache 2.0 license in
/usr/share/common-licenses/Apache-2.0
License: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,49 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: unicase
Upstream-Contact: Sean McArthur <sean@seanmonstar.com>
Source: https://github.com/seanmonstar/unicase
Files: *
Copyright: FIXME (overlay) UNKNOWN-YEARS Sean McArthur <sean@seanmonstar.com>
License: MIT or Apache-2.0
Comment:
FIXME (overlay): Since upstream copyright years are not available in
Cargo.toml, they were extracted from the upstream Git repository. This may not
be correct information so you should review and fix this before uploading to
the archive.
Files: ./LICENSE-MIT
Copyright: 2014-2017 Sean McArthur
License: UNKNOWN-LICENSE; FIXME (overlay)
Comment:
FIXME (overlay): These notices are extracted from files. Please review them
before uploading to the archive.
Files: debian/*
Copyright:
2018-2020 Debian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net>
2018-2020 kpcyrd <git@rxv.cc>
License: MIT or Apache-2.0
License: Apache-2.0
Debian systems provide the Apache 2.0 license in
/usr/share/common-licenses/Apache-2.0
License: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,2 @@
overlay = "."
uploaders = ["kpcyrd <git@rxv.cc>"]

6
debian-orig/rules Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/make -f
%:
dh $@ --buildsystem cargo
override_dh_auto_test:
dh_auto_test -- test --all

View File

@ -0,0 +1 @@
3.0 (quilt)

19
debian-orig/tests/control Normal file
View File

@ -0,0 +1,19 @@
Test-Command: /usr/share/cargo/bin/cargo-auto-test unicase 2.6.0 --all-targets --all-features
Features: test-name=rust-unicase:@
Depends: dh-cargo (>= 18), @
Restrictions: allow-stderr, skip-not-installable
Test-Command: /usr/share/cargo/bin/cargo-auto-test unicase 2.6.0 --all-targets
Features: test-name=librust-unicase-dev:default
Depends: dh-cargo (>= 18), @
Restrictions: allow-stderr, skip-not-installable
Test-Command: /usr/share/cargo/bin/cargo-auto-test unicase 2.6.0 --all-targets --no-default-features --features nightly
Features: test-name=librust-unicase-dev:nightly
Depends: dh-cargo (>= 18), @
Restrictions: allow-stderr, skip-not-installable
Test-Command: /usr/share/cargo/bin/cargo-auto-test unicase 2.6.0 --all-targets --no-default-features
Features: test-name=librust-unicase-dev:
Depends: dh-cargo (>= 18), @
Restrictions: allow-stderr, skip-not-installable

4
debian-orig/watch Normal file
View File

@ -0,0 +1,4 @@
version=4
opts=filenamemangle=s/.*\/(.*)\/download/unicase-$1\.tar\.gz/g,\
uversionmangle=s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha)\d*)$/$1~$2/ \
https://qa.debian.org/cgi-bin/fakeupstream.cgi?upstream=crates.io/unicase .*/crates/unicase/@ANY_VERSION@/download

187
src/ascii.rs Normal file
View File

@ -0,0 +1,187 @@
use alloc::string::String;
#[cfg(__unicase__iter_cmp)]
use core::cmp::Ordering;
use core::fmt;
use core::hash::{Hash, Hasher};
use core::ops::{Deref, DerefMut};
use core::str::FromStr;
#[cfg(not(__unicase__core_and_alloc))]
#[allow(deprecated, unused)]
use std::ascii::AsciiExt;
use super::{Ascii, Encoding, UniCase};
impl<S> Ascii<S> {
#[inline]
#[cfg(__unicase__const_fns)]
pub const fn new(s: S) -> Ascii<S> {
Ascii(s)
}
/// Construct a new `Ascii`.
///
/// For Rust versions >= 1.31, this is a `const fn`.
#[inline]
#[cfg(not(__unicase__const_fns))]
pub fn new(s: S) -> Ascii<S> {
Ascii(s)
}
#[cfg(__unicase_const_fns)]
pub const fn into_unicase(self) -> UniCase<S> {
UniCase(Encoding::Ascii(self))
}
#[cfg(not(__unicase_const_fns))]
pub fn into_unicase(self) -> UniCase<S> {
UniCase(Encoding::Ascii(self))
}
#[inline]
pub fn into_inner(self) -> S {
self.0
}
}
impl<S> Deref for Ascii<S> {
type Target = S;
#[inline]
fn deref<'a>(&'a self) -> &'a S {
&self.0
}
}
impl<S> DerefMut for Ascii<S> {
#[inline]
fn deref_mut<'a>(&'a mut self) -> &'a mut S {
&mut self.0
}
}
#[cfg(__unicase__iter_cmp)]
impl<T: AsRef<str>> PartialOrd for Ascii<T> {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
#[cfg(__unicase__iter_cmp)]
impl<T: AsRef<str>> Ord for Ascii<T> {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
let self_chars = self.as_ref().chars().map(|c| c.to_ascii_lowercase());
let other_chars = other.as_ref().chars().map(|c| c.to_ascii_lowercase());
self_chars.cmp(other_chars)
}
}
impl<S: AsRef<str>> AsRef<str> for Ascii<S> {
#[inline]
fn as_ref(&self) -> &str {
self.0.as_ref()
}
}
impl<S: fmt::Display> fmt::Display for Ascii<S> {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, fmt)
}
}
impl<S1: AsRef<str>> PartialEq<Ascii<S1>> for String {
#[inline]
fn eq(&self, other: &Ascii<S1>) -> bool {
other == self
}
}
impl<'a, S1: AsRef<str>> PartialEq<Ascii<S1>> for &'a str {
#[inline]
fn eq(&self, other: &Ascii<S1>) -> bool {
other == self
}
}
impl<S1: AsRef<str>, S2: AsRef<str>> PartialEq<S2> for Ascii<S1> {
#[inline]
fn eq(&self, other: &S2) -> bool {
self.as_ref().eq_ignore_ascii_case(other.as_ref())
}
}
impl<S: AsRef<str>> Eq for Ascii<S> {}
impl<S: FromStr> FromStr for Ascii<S> {
type Err = <S as FromStr>::Err;
fn from_str(s: &str) -> Result<Ascii<S>, <S as FromStr>::Err> {
s.parse().map(Ascii)
}
}
impl<S: AsRef<str>> Hash for Ascii<S> {
#[inline]
fn hash<H: Hasher>(&self, hasher: &mut H) {
for byte in self.as_ref().bytes().map(|b| b.to_ascii_lowercase()) {
hasher.write_u8(byte);
}
}
}
#[cfg(test)]
mod tests {
use ::Ascii;
use std::hash::{Hash, Hasher};
#[cfg(not(__unicase__default_hasher))]
use std::hash::SipHasher as DefaultHasher;
#[cfg(__unicase__default_hasher)]
use std::collections::hash_map::DefaultHasher;
fn hash<T: Hash>(t: &T) -> u64 {
let mut s = DefaultHasher::new();
t.hash(&mut s);
s.finish()
}
#[test]
fn test_case_insensitive() {
let a = Ascii("foobar");
let b = Ascii("FOOBAR");
assert_eq!(a, b);
assert_eq!(hash(&a), hash(&b));
assert_eq!(a, "fooBar");
assert_eq!("fooBar", a);
assert_eq!(String::from("fooBar"), a);
assert_eq!(a, String::from("fooBar"));
}
#[cfg(feature = "nightly")]
#[bench]
fn bench_ascii_eq(b: &mut ::test::Bencher) {
b.bytes = b"foobar".len() as u64;
b.iter(|| assert_eq!(Ascii("foobar"), Ascii("FOOBAR")));
}
#[cfg(__unicase__iter_cmp)]
#[test]
fn test_case_cmp() {
assert!(Ascii("foobar") == Ascii("FOOBAR"));
assert!(Ascii("a") < Ascii("B"));
assert!(Ascii("A") < Ascii("b"));
assert!(Ascii("aa") > Ascii("a"));
assert!(Ascii("a") < Ascii("aa"));
assert!(Ascii("a") < Ascii("AA"));
}
#[cfg(__unicase__const_fns)]
#[test]
fn test_ascii_new_const() {
const _ASCII: Ascii<&'static str> = Ascii::new("");
}
}

465
src/lib.rs Normal file
View File

@ -0,0 +1,465 @@
#![cfg_attr(test, deny(missing_docs))]
#![cfg_attr(test, deny(warnings))]
#![doc(html_root_url = "https://docs.rs/unicase/2.6.0")]
#![cfg_attr(feature = "nightly", feature(test))]
#![cfg_attr(
all(
__unicase__core_and_alloc,
not(test),
),
no_std,
)]
//! # UniCase
//!
//! UniCase provides a way of specifying strings that are case-insensitive.
//!
//! UniCase supports full [Unicode case
//! folding](https://www.w3.org/International/wiki/Case_folding). It can also
//! utilize faster ASCII case comparisons, if both strings are ASCII.
//!
//! Using the `UniCase::new()` constructor will check the string to see if it
//! is all ASCII. When a `UniCase` is compared against another, if both are
//! ASCII, it will use the faster comparison.
//!
//! There also exists the `Ascii` type in this crate, which will always assume
//! to use the ASCII case comparisons, if the encoding is already known.
//!
//! ## Example
//!
//! ```rust
//! use unicase::UniCase;
//!
//! let a = UniCase::new("Maße");
//! let b = UniCase::new("MASSE");
//! let c = UniCase::new("mase");
//!
//! assert_eq!(a, b);
//! assert!(b != c);
//! ```
//!
//! ## Ascii
//!
//! ```rust
//! use unicase::Ascii;
//!
//! let a = Ascii::new("foobar");
//! let b = Ascii::new("FoObAr");
//!
//! assert_eq!(a, b);
//! ```
#[cfg(feature = "nightly")]
extern crate test;
#[cfg(all(__unicase__core_and_alloc, not(test)))]
extern crate alloc;
#[cfg(all(__unicase__core_and_alloc, not(test)))]
use alloc::string::String;
#[cfg(not(all(__unicase__core_and_alloc, not(test))))]
extern crate std as alloc;
#[cfg(not(all(__unicase__core_and_alloc, not(test))))]
extern crate std as core;
use alloc::borrow::Cow;
#[cfg(__unicase__iter_cmp)]
use core::cmp::Ordering;
use core::fmt;
use core::hash::{Hash, Hasher};
use core::ops::{Deref, DerefMut};
use core::str::FromStr;
use self::unicode::Unicode;
mod ascii;
mod unicode;
/// Case Insensitive wrapper of strings.
#[derive(Clone, Copy)]
pub struct UniCase<S>(Encoding<S>);
/// Case Insensitive wrapper of Ascii strings.
#[derive(Clone, Copy, Debug, Default)]
pub struct Ascii<S>(S);
/// Compare two string-like types for case-less equality, using unicode folding.
///
/// Equivalent to `UniCase::new(left) == UniCase::new(right)`.
///
/// Note: This will perform a scan for ASCII characters before doing the
/// the comparison. See `UniCase` for more information.
#[inline]
pub fn eq<S: AsRef<str> + ?Sized>(left: &S, right: &S) -> bool {
UniCase::new(left) == UniCase::new(right)
}
/// Compare two string-like types for case-less equality, ignoring ASCII case.
///
/// Equivalent to `Ascii::new(left) == Ascii::new(right)`.
#[inline]
pub fn eq_ascii<S: AsRef<str> + ?Sized>(left: &S, right: &S) -> bool {
Ascii(left) == Ascii(right)
}
#[derive(Clone, Copy, Debug)]
enum Encoding<S> {
Ascii(Ascii<S>),
Unicode(Unicode<S>),
}
macro_rules! inner {
(mut $e:expr) => ({
match &mut $e {
&mut Encoding::Ascii(ref mut s) => &mut s.0,
&mut Encoding::Unicode(ref mut s) => &mut s.0,
}
});
($e:expr) => ({
match &$e {
&Encoding::Ascii(ref s) => &s.0,
&Encoding::Unicode(ref s) => &s.0,
}
});
}
impl<S: AsRef<str> + Default> Default for UniCase<S> {
fn default() -> Self {
Self::new(Default::default())
}
}
impl<S: AsRef<str>> UniCase<S> {
/// Creates a new `UniCase`.
///
/// Note: This scans the text to determine if it is all ASCII or not.
pub fn new(s: S) -> UniCase<S> {
#[cfg(not(__unicase__core_and_alloc))]
#[allow(deprecated, unused)]
use std::ascii::AsciiExt;
if s.as_ref().is_ascii() {
UniCase(Encoding::Ascii(Ascii(s)))
} else {
UniCase(Encoding::Unicode(Unicode(s)))
}
}
}
impl<S> UniCase<S> {
/// Creates a new `UniCase`, skipping the ASCII check.
#[cfg(__unicase__const_fns)]
pub const fn unicode(s: S) -> UniCase<S> {
UniCase(Encoding::Unicode(Unicode(s)))
}
/// Creates a new `UniCase`, skipping the ASCII check.
///
/// For Rust versions >= 1.31, this is a `const fn`.
#[cfg(not(__unicase__const_fns))]
pub fn unicode(s: S) -> UniCase<S> {
UniCase(Encoding::Unicode(Unicode(s)))
}
/// Creates a new `UniCase` which performs only ASCII case folding.
#[cfg(__unicase__const_fns)]
pub const fn ascii(s: S) -> UniCase<S> {
UniCase(Encoding::Ascii(Ascii(s)))
}
/// Creates a new `UniCase` which performs only ASCII case folding.
///
/// For Rust versions >= 1.31, this is a `const fn`.
#[cfg(not(__unicase__const_fns))]
pub fn ascii(s: S) -> UniCase<S> {
UniCase(Encoding::Ascii(Ascii(s)))
}
/// Return `true` if this instance will only perform ASCII case folding.
pub fn is_ascii(&self) -> bool {
match self.0 {
Encoding::Ascii(_) => true,
Encoding::Unicode(_) => false,
}
}
/// Unwraps the inner value held by this `UniCase`.
#[inline]
pub fn into_inner(self) -> S {
match self.0 {
Encoding::Ascii(s) => s.0,
Encoding::Unicode(s) => s.0,
}
}
}
impl<S> Deref for UniCase<S> {
type Target = S;
#[inline]
fn deref<'a>(&'a self) -> &'a S {
inner!(self.0)
}
}
impl<S> DerefMut for UniCase<S> {
#[inline]
fn deref_mut<'a>(&'a mut self) -> &'a mut S {
inner!(mut self.0)
}
}
impl<S: AsRef<str>> AsRef<str> for UniCase<S> {
#[inline]
fn as_ref(&self) -> &str {
inner!(self.0).as_ref()
}
}
impl<S: fmt::Debug> fmt::Debug for UniCase<S> {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(inner!(self.0), fmt)
}
}
impl<S: fmt::Display> fmt::Display for UniCase<S> {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(inner!(self.0), fmt)
}
}
impl<S1: AsRef<str>, S2: AsRef<str>> PartialEq<UniCase<S2>> for UniCase<S1> {
#[inline]
fn eq(&self, other: &UniCase<S2>) -> bool {
match (&self.0, &other.0) {
(&Encoding::Ascii(ref x), &Encoding::Ascii(ref y)) => x == y,
(&Encoding::Unicode(ref x), &Encoding::Unicode(ref y)) => x == y,
(&Encoding::Ascii(ref x), &Encoding::Unicode(ref y)) => &Unicode(x.as_ref()) == y,
(&Encoding::Unicode(ref x), &Encoding::Ascii(ref y)) => x == &Unicode(y.as_ref()),
}
}
}
impl<S: AsRef<str>> Eq for UniCase<S> {}
impl<S: AsRef<str>> Hash for UniCase<S> {
#[inline]
fn hash<H: Hasher>(&self, hasher: &mut H) {
match self.0 {
Encoding::Ascii(ref s) => s.hash(hasher),
Encoding::Unicode(ref s) => s.hash(hasher)
}
}
}
impl<S> From<Ascii<S>> for UniCase<S> {
fn from(ascii: Ascii<S>) -> Self {
UniCase(Encoding::Ascii(ascii))
}
}
macro_rules! from_impl {
($from:ty => $to:ty; $by:ident) => (
impl<'a> From<$from> for UniCase<$to> {
fn from(s: $from) -> Self {
UniCase::unicode(s.$by())
}
}
);
($from:ty => $to:ty) => ( from_impl!($from => $to; into); )
}
macro_rules! into_impl {
($to:ty) => (
impl<'a> Into<$to> for UniCase<$to> {
fn into(self) -> $to {
self.into_inner()
}
}
);
}
impl<S: AsRef<str>> From<S> for UniCase<S> {
fn from(s: S) -> Self {
UniCase::unicode(s)
}
}
from_impl!(&'a str => Cow<'a, str>);
from_impl!(String => Cow<'a, str>);
from_impl!(&'a str => String);
from_impl!(Cow<'a, str> => String; into_owned);
from_impl!(&'a String => &'a str; as_ref);
into_impl!(&'a str);
into_impl!(String);
into_impl!(Cow<'a, str>);
#[cfg(__unicase__iter_cmp)]
impl<T: AsRef<str>> PartialOrd for UniCase<T> {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
#[cfg(__unicase__iter_cmp)]
impl<T: AsRef<str>> Ord for UniCase<T> {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
match (&self.0, &other.0) {
(&Encoding::Ascii(ref x), &Encoding::Ascii(ref y)) => x.cmp(y),
(&Encoding::Unicode(ref x), &Encoding::Unicode(ref y)) => x.cmp(y),
(&Encoding::Ascii(ref x), &Encoding::Unicode(ref y)) => Unicode(x.as_ref()).cmp(&Unicode(y.0.as_ref())),
(&Encoding::Unicode(ref x), &Encoding::Ascii(ref y)) => Unicode(x.0.as_ref()).cmp(&Unicode(y.as_ref())),
}
}
}
impl<S: FromStr + AsRef<str>> FromStr for UniCase<S> {
type Err = <S as FromStr>::Err;
fn from_str(s: &str) -> Result<UniCase<S>, Self::Err> {
s.parse().map(UniCase::new)
}
}
#[cfg(test)]
mod tests {
use super::UniCase;
use std::hash::{Hash, Hasher};
#[cfg(not(__unicase__default_hasher))]
use std::hash::SipHasher as DefaultHasher;
#[cfg(__unicase__default_hasher)]
use std::collections::hash_map::DefaultHasher;
fn hash<T: Hash>(t: &T) -> u64 {
let mut s = DefaultHasher::new();
t.hash(&mut s);
s.finish()
}
#[test]
fn test_copy_for_refs() {
fn foo<T>(_: UniCase<T>) {}
let a = UniCase::new("foobar");
foo(a);
foo(a);
}
#[test]
fn test_eq_ascii() {
let a = UniCase::new("foobar");
let b = UniCase::new("FOOBAR");
let c = UniCase::ascii("FoObAr");
assert_eq!(a, b);
assert_eq!(b, a);
assert_eq!(a, c);
assert_eq!(c, a);
assert_eq!(hash(&a), hash(&b));
assert_eq!(hash(&a), hash(&c));
assert!(a.is_ascii());
assert!(b.is_ascii());
assert!(c.is_ascii());
}
#[test]
fn test_eq_unicode() {
let a = UniCase::new("στιγμας");
let b = UniCase::new("στιγμασ");
assert_eq!(a, b);
assert_eq!(b, a);
assert_eq!(hash(&a), hash(&b));
}
#[test]
fn test_eq_unicode_left_is_substring() {
// https://github.com/seanmonstar/unicase/issues/38
let a = UniCase::unicode("foo");
let b = UniCase::unicode("foobar");
assert!(a != b);
assert!(b != a);
}
#[cfg(feature = "nightly")]
#[bench]
fn bench_unicase_ascii(b: &mut ::test::Bencher) {
b.bytes = b"foobar".len() as u64;
let x = UniCase::new("foobar");
let y = UniCase::new("FOOBAR");
b.iter(|| assert_eq!(x, y));
}
#[cfg(feature = "nightly")]
static SUBJECT: &'static [u8] = b"ffoo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz oo bar baz quux herp derp";
#[cfg(feature = "nightly")]
#[inline(never)]
fn is_ascii(bytes: &[u8]) -> bool {
#[allow(unused, deprecated)]
use std::ascii::AsciiExt;
bytes.is_ascii()
}
#[cfg(feature = "nightly")]
#[bench]
fn bench_is_ascii(b: &mut ::test::Bencher) {
b.iter(|| assert!(is_ascii(SUBJECT)));
}
#[cfg(feature = "nightly")]
#[bench]
fn bench_is_utf8(b: &mut ::test::Bencher) {
b.iter(|| assert!(::std::str::from_utf8(SUBJECT).is_ok()));
}
#[cfg(__unicase__iter_cmp)]
#[test]
fn test_case_cmp() {
assert!(UniCase::new("a") < UniCase::new("B"));
assert!(UniCase::new("A") < UniCase::new("b"));
assert!(UniCase::new("aa") > UniCase::new("a"));
assert!(UniCase::new("a") < UniCase::new("aa"));
assert!(UniCase::new("a") < UniCase::new("AA"));
}
#[test]
fn test_from_impls() {
let view: &'static str = "foobar";
let _: UniCase<&'static str> = view.into();
let _: UniCase<&str> = view.into();
let _: UniCase<String> = view.into();
let owned: String = view.to_owned();
let _: UniCase<&str> = (&owned).into();
let _: UniCase<String> = owned.into();
}
#[test]
fn test_into_impls() {
let view: UniCase<&'static str> = UniCase::new("foobar");
let _: &'static str = view.into();
let _: &str = view.into();
let owned: UniCase<String> = "foobar".into();
let _: String = owned.clone().into();
let _: &str = owned.as_ref();
}
#[cfg(__unicase__const_fns)]
#[test]
fn test_unicase_unicode_const() {
const _UNICASE: UniCase<&'static str> = UniCase::unicode("");
}
}

1995
src/unicode/map.rs Normal file

File diff suppressed because it is too large Load Diff

201
src/unicode/mod.rs Normal file
View File

@ -0,0 +1,201 @@
#[cfg(__unicase__iter_cmp)]
use core::cmp::Ordering;
use core::hash::{Hash, Hasher};
use self::map::lookup;
mod map;
#[derive(Clone, Copy, Debug, Default)]
pub struct Unicode<S>(pub S);
impl<S1: AsRef<str>, S2: AsRef<str>> PartialEq<Unicode<S2>> for Unicode<S1> {
#[inline]
fn eq(&self, other: &Unicode<S2>) -> bool {
let mut left = self.0.as_ref().chars().flat_map(lookup);
let mut right = other.0.as_ref().chars().flat_map(lookup);
// inline Iterator::eq since not added until Rust 1.5
loop {
let x = match left.next() {
None => return right.next().is_none(),
Some(val) => val,
};
let y = match right.next() {
None => return false,
Some(val) => val,
};
if x != y {
return false;
}
}
}
}
impl<S: AsRef<str>> Eq for Unicode<S> {}
#[cfg(__unicase__iter_cmp)]
impl<T: AsRef<str>> PartialOrd for Unicode<T> {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
#[cfg(__unicase__iter_cmp)]
impl<T: AsRef<str>> Ord for Unicode<T> {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
let self_chars = self.0.as_ref().chars().flat_map(lookup);
let other_chars = other.0.as_ref().chars().flat_map(lookup);
self_chars.cmp(other_chars)
}
}
impl<S: AsRef<str>> Hash for Unicode<S> {
#[inline]
fn hash<H: Hasher>(&self, hasher: &mut H) {
let mut buf = [0; 4];
for c in self.0.as_ref().chars().flat_map(|c| lookup(c)) {
let len = char_to_utf8(c, &mut buf);
hasher.write(&buf[..len])
}
}
}
#[inline]
fn char_to_utf8(c: char, dst: &mut [u8; 4]) -> usize {
const TAG_CONT: u8 = 0b1000_0000;
const TAG_TWO_B: u8 = 0b1100_0000;
const TAG_THREE_B: u8 = 0b1110_0000;
const TAG_FOUR_B: u8 = 0b1111_0000;
let code = c as u32;
if code <= 0x7F {
dst[0] = code as u8;
1
} else if code <= 0x7FF {
dst[0] = (code >> 6 & 0x1F) as u8 | TAG_TWO_B;
dst[1] = (code & 0x3F) as u8 | TAG_CONT;
2
} else if code <= 0xFFFF {
dst[0] = (code >> 12 & 0x0F) as u8 | TAG_THREE_B;
dst[1] = (code >> 6 & 0x3F) as u8 | TAG_CONT;
dst[2] = (code & 0x3F) as u8 | TAG_CONT;
3
} else {
dst[0] = (code >> 18 & 0x07) as u8 | TAG_FOUR_B;
dst[1] = (code >> 12 & 0x3F) as u8 | TAG_CONT;
dst[2] = (code >> 6 & 0x3F) as u8 | TAG_CONT;
dst[3] = (code & 0x3F) as u8 | TAG_CONT;
4
}
}
// 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),
}
impl Iterator for Fold {
type Item = char;
#[inline]
fn next(&mut self) -> Option<char> {
match *self {
Fold::Zero => None,
Fold::One(one) => {
*self = Fold::Zero;
Some(one)
},
Fold::Two(one, two) => {
*self = Fold::One(two);
Some(one)
},
Fold::Three(one, two, three) => {
*self = Fold::Two(one, two);
Some(three)
}
}
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
match *self {
Fold::Zero => (0, Some(0)),
Fold::One(..) => (1, Some(1)),
Fold::Two(..) => (2, Some(2)),
Fold::Three(..) => (3, Some(3))
}
}
}
impl From<(char,)> for Fold {
#[inline]
fn from((one,): (char,)) -> Fold {
Fold::One(one)
}
}
impl From<(char, char)> for Fold {
#[inline]
fn from((one, two): (char, char)) -> Fold {
Fold::Two(one, two)
}
}
impl From<(char, char, char)> for Fold {
#[inline]
fn from((one, two, three): (char, char, char)) -> Fold {
Fold::Three(one, two, three)
}
}
}
#[cfg(test)]
mod tests {
use super::Unicode;
macro_rules! eq {
($left:expr, $right:expr) => ({
assert_eq!(Unicode($left), Unicode($right));
});
}
#[test]
fn test_ascii_folding() {
eq!("foo bar", "FoO BAR");
}
#[test]
fn test_simple_case_folding() {
eq!("στιγμας", "στιγμασ");
}
#[test]
fn test_full_case_folding() {
eq!("flour", "flour");
eq!("Maße", "MASSE");
eq!("ᾲ στο διάολο", "ὰι στο διάολο");
}
#[cfg(feature = "nightly")]
#[bench]
fn bench_ascii_folding(b: &mut ::test::Bencher) {
b.bytes = b"foo bar".len() as u64;
b.iter(|| eq!("foo bar", "FoO BAR"));
}
#[cfg(feature = "nightly")]
#[bench]
fn bench_simple_case_folding(b: &mut ::test::Bencher) {
b.bytes = "στιγμας".len() as u64;
b.iter(|| eq!("στιγμας", "στιγμασ"));
}
}