Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
34 changes: 31 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ jobs:
key: clippy-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}y
- run: cargo clippy --all --all-targets

test:
name: test
test-no_std:
name: test no_std on Rust 1.81.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: sfackler/actions/rustup@master
with:
version: 1.56.0
version: 1.81.0
- run: echo "version=$(rustc --version)" >> $GITHUB_OUTPUT
id: rust-version
- uses: actions/cache@v3
Expand All @@ -74,3 +74,31 @@ jobs:
path: target
key: test-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}y
- run: cargo test --all

test-std:
name: test std on Rust 1.56.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: sfackler/actions/rustup@master
with:
version: 1.56.0
- run: echo "version=$(rustc --version)" >> $GITHUB_OUTPUT
id: rust-version
- uses: actions/cache@v3
with:
path: ~/.cargo/registry/index
key: index-${{ runner.os }}-${{ github.run_number }}
restore-keys: |
index-${{ runner.os }}-
- run: cargo generate-lockfile
- uses: actions/cache@v3
with:
path: ~/.cargo/registry/cache
key: registry-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- run: cargo fetch
- uses: actions/cache@v3
with:
path: target
key: test-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}y
- run: cargo test --all --features=std
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ readme = "README.md"
unicode-bidi = "0.3"
unicode-normalization = "0.1"
unicode-properties = "0.1.1"

[features]
std = []
15 changes: 13 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
//! An implementation of the "stringprep" algorithm defined in [RFC 3454][].
//!
//! [RFC 3454]: https://tools.ietf.org/html/rfc3454
#![no_std]
#![warn(missing_docs)]
extern crate alloc;
extern crate unicode_bidi;
extern crate unicode_normalization;
extern crate unicode_properties;

use std::borrow::Cow;
use std::fmt;
#[cfg(feature = "std")]
extern crate std;

use alloc::borrow::Cow;
use alloc::string::String;
use core::fmt;
use unicode_normalization::UnicodeNormalization;
use unicode_properties::{GeneralCategoryGroup, UnicodeGeneralCategory};

Expand Down Expand Up @@ -44,7 +50,12 @@ impl fmt::Display for Error {
}
}

// This is only needed for Rust versions older than 1.81.0, before core::error::Error got
// stabilized.
#[cfg(feature = "std")]
impl std::error::Error for Error {}
#[cfg(not(feature = "std"))]
impl core::error::Error for Error {}

/// Prepares a string with the SASLprep profile of the stringprep algorithm.
///
Expand Down
4 changes: 2 additions & 2 deletions src/tables.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Character Tables
use std::cmp::Ordering;
use std::str::Chars;
use core::cmp::Ordering;
use core::str::Chars;
use unicode_bidi::{bidi_class, BidiClass};
use unicode_properties::{GeneralCategoryGroup, UnicodeGeneralCategory};

Expand Down