Skip to content

Commit

Permalink
Merge pull request #20 from artichoke/prep-for-wip-release
Browse files Browse the repository at this point in the history
Prepare for 0.0.1 release
  • Loading branch information
lopopolo authored Feb 15, 2021
2 parents 7117cfc + 182220b commit e25ce89
Show file tree
Hide file tree
Showing 12 changed files with 1,173 additions and 265 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- name: Test with no default features
run: cargo test --no-default-features

- name: Test with alloc feature
run: cargo test --no-default-features --features alloc

rust-minimal-versions:
name: Compile with minimum dependency versions
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "roe"
version = "0.1.0" # remember to set `html_root_url` in `src/lib.rs`.
version = "0.0.1" # remember to set `html_root_url` in `src/lib.rs`.
authors = ["Ryan Lopopolo <[email protected]>"]
license = "MIT"
edition = "2018"
Expand All @@ -16,7 +16,7 @@ include = ["src/**/*", "tests/**/*", "LICENSE", "README.md"]
[features]
default = ["std"]
# Enable dependency on `std`, the Rust standard library. This feature enables
# `std::error::Error` implementations on the error types in `boba`.
# `std::error::Error` implementations on the error types in `roe`.
std = ["alloc"]
# Enable a dependency on `alloc`, The Rust collections library. This feature
# enables APIs that depend on `Vec` and `String`.
Expand All @@ -33,6 +33,6 @@ version-sync = "0.9, >= 0.9.2"

[package.metadata.docs.rs]
# This sets the default target to `x86_64-unknown-linux-gnu` and only builds
# that target. `boba` has the same API and code on all targets.
# that target. `roe` has the same API and code on all targets.
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = ["--cfg", "docsrs"]
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,30 @@ and uppercase forms. This crate is used to implement [`String#capitalize`],

This crate depends on [`bstr`].

## Status

This crate is currently a _work in progress_. When the API is complete, Roe will
support lowercase, uppercase, titlecase, and case folding iterators for
conventionally UTF-8 byte slices.

Roe will implement support for full, Turkic, ASCII, and case folding transforms.

## Usage

Add this to your `Cargo.toml`:

```toml
[dependencies]
roe = "0.1"
roe = "0.0.1"
```

Then convert case like:

```rust
assert_eq!(roe::lowercase("Pineapple").collect::<Vec<_>>(), b"pineapple");
assert_eq!(roe::upercase(b"xexax").collect::<Vec<_>>(), b"XEXAX");
use roe::{LowercaseMode, UppercaseMode};

assert_eq!(roe::lowercase(b"Artichoke Ruby", LowercaseMode::Ascii).collect::<Vec<_>>(), b"artichoke ruby");
assert_eq!(roe::uppercase("Αύριο".as_bytes(), UppercaseMode::Full).collect::<Vec<_>>(), "ΑΎΡΙΟ".as_bytes());
```

## Crate Features
Expand All @@ -47,8 +57,8 @@ assert_eq!(roe::upercase(b"xexax").collect::<Vec<_>>(), b"XEXAX");
feature enables [`std::error::Error`] implementations on error types in this
crate. Enabling the **std** feature also enables the **alloc** feature.
- **alloc** - Adds a dependency on [`alloc`], the Rust allocation and
collections library. This feature enables APIs that depend on [`Vec`] and
[`String`].
collections library. This feature enables APIs that allocate [`String`] or
[`Vec`].

## License

Expand All @@ -69,10 +79,8 @@ assert_eq!(roe::upercase(b"xexax").collect::<Vec<_>>(), b"XEXAX");
[`symbol#upcase`]: https://ruby-doc.org/core-2.6.3/Symbol.html#method-i-upcase
[artichoke ruby]: https://github.com/artichoke/artichoke
[`bstr`]: https://crates.io/crates/bstr
[`alloc`]: https://doc.rust-lang.org/stable/alloc/index.html
[`std`]: https://doc.rust-lang.org/stable/std/index.html
[`std::error::error`]:
https://doc.rust-lang.org/stable/std/error/trait.Error.html
[`vec`]: https://doc.rust-lang.org/stable/alloc/vec/struct.Vec.html
[`alloc`]: https://doc.rust-lang.org/alloc/index.html
[`std`]: https://doc.rust-lang.org/std/index.html
[`std::error::error`]: https://doc.rust-lang.org/std/error/trait.Error.html
[`string`]: https://doc.rust-lang.org/stable/alloc/string/struct.String.html
[cargo-fuzz]: https://crates.io/crates/cargo-fuzz
[`vec`]: https://doc.rust-lang.org/stable/alloc/vec/struct.Vec.html
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace :lint do
FileList['**/{build,lib,main}.rs'].each do |root|
FileUtils.touch(root)
end
sh 'cargo clippy --workspace --all-features'
sh 'cargo clippy --workspace --all-features --all-targets'
end

desc 'Lint Rust sources with Clippy restriction pass (unenforced lints)'
Expand Down
2 changes: 2 additions & 0 deletions src/ascii/lowercase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use alloc::vec::Vec;
/// [`String#downcase!`]: https://ruby-doc.org/core-2.6.3/String.html#method-i-downcase-21
/// [slice-primitive]: https://doc.rust-lang.org/std/primitive.slice.html#method.make_ascii_lowercase
#[inline]
#[allow(clippy::module_name_repetitions)]
pub fn make_ascii_lowercase<T: AsMut<[u8]>>(mut slice: T) {
let slice = slice.as_mut();
slice.make_ascii_lowercase();
Expand Down Expand Up @@ -62,6 +63,7 @@ pub fn make_ascii_lowercase<T: AsMut<[u8]>>(mut slice: T) {
#[inline]
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
#[allow(clippy::module_name_repetitions)]
pub fn to_ascii_lowercase<T: AsRef<[u8]>>(slice: T) -> Vec<u8> {
let slice = slice.as_ref();
slice.to_ascii_lowercase()
Expand Down
6 changes: 4 additions & 2 deletions src/ascii/titlecase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::vec::Vec;
/// Converts the given slice to its ASCII title case equivalent in-place.
///
/// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z' in the first byte;
/// subsequent bytes with ASCII letters 'A' to 'Z' are mapped to 'a' to 'z;
/// subsequent bytes with ASCII letters 'A' to 'Z' are mapped to 'a' to 'z';
/// non-ASCII letters are unchanged.
///
/// This function can be used to implement [`String#capitalize!`] for ASCII
Expand Down Expand Up @@ -40,6 +40,7 @@ use alloc::vec::Vec;
///
/// [`String#capitalize!`]: https://ruby-doc.org/core-2.6.3/String.html#method-i-capitalize-21
#[inline]
#[allow(clippy::module_name_repetitions)]
pub fn make_ascii_titlecase<T: AsMut<[u8]>>(slice: &mut T) {
let slice = slice.as_mut();
if let Some((head, tail)) = slice.split_first_mut() {
Expand All @@ -52,7 +53,7 @@ pub fn make_ascii_titlecase<T: AsMut<[u8]>>(slice: &mut T) {
/// mapped to its ASCII title case equivalent.
///
/// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z' in the first byte;
/// subsequent bytes with ASCII letters 'A' to 'Z' are mapped to 'a' to 'z;
/// subsequent bytes with ASCII letters 'A' to 'Z' are mapped to 'a' to 'z';
/// non-ASCII letters are unchanged.
///
/// This function can be used to implement [`String#capitalize`] and
Expand All @@ -76,6 +77,7 @@ pub fn make_ascii_titlecase<T: AsMut<[u8]>>(slice: &mut T) {
#[inline]
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
#[allow(clippy::module_name_repetitions)]
pub fn to_ascii_titlecase<T: AsRef<[u8]>>(slice: T) -> Vec<u8> {
let slice = slice.as_ref();
let mut titlecase = slice.to_ascii_lowercase();
Expand Down
2 changes: 2 additions & 0 deletions src/ascii/uppercase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use alloc::vec::Vec;
/// [`String#upcase!`]: https://ruby-doc.org/core-2.6.3/String.html#method-i-upcase-21
/// [slice-primitive]: https://doc.rust-lang.org/std/primitive.u8.html#method.make_ascii_uppercase
#[inline]
#[allow(clippy::module_name_repetitions)]
pub fn make_ascii_uppercase<T: AsMut<[u8]>>(slice: &mut T) {
let slice = slice.as_mut();
slice.make_ascii_uppercase();
Expand Down Expand Up @@ -62,6 +63,7 @@ pub fn make_ascii_uppercase<T: AsMut<[u8]>>(slice: &mut T) {
#[inline]
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
#[allow(clippy::module_name_repetitions)]
pub fn to_ascii_uppercase<T: AsRef<[u8]>>(slice: T) -> Vec<u8> {
let slice = slice.as_ref();
slice.to_ascii_uppercase()
Expand Down
Loading

0 comments on commit e25ce89

Please sign in to comment.