From 92838fd550eed6db1e67869dcce49fbe10082631 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 22 Jun 2024 22:27:17 +0200 Subject: [PATCH] Make this crate no_std MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As nothing actually depends on std, there is no need to keep a dependency on it. This allows users such as the jid crate to actually be no_std as well. Now that core::error::Error got stabilized, we don’t need anything from std any longer, but this bumps the minimum supported Rust version to 1.81.0. --- .github/workflows/ci.yml | 2 +- Cargo.toml | 1 + src/lib.rs | 9 ++++++--- src/tables.rs | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 541d58a..682dd21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: - 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 diff --git a/Cargo.toml b/Cargo.toml index e7223e5..5b73efd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ license = "MIT/Apache-2.0" description = "An implementation of the stringprep algorithm" repository = "https://github.com/sfackler/rust-stringprep" readme = "README.md" +rust-version = "1.81.0" # For core::error::Error [dependencies] unicode-bidi = "0.3" diff --git a/src/lib.rs b/src/lib.rs index 7027761..8945ccb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,13 +1,16 @@ //! 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; +use alloc::borrow::Cow; +use alloc::string::String; +use core::fmt; use unicode_normalization::UnicodeNormalization; use unicode_properties::{GeneralCategoryGroup, UnicodeGeneralCategory}; @@ -44,7 +47,7 @@ impl fmt::Display for Error { } } -impl std::error::Error for Error {} +impl core::error::Error for Error {} /// Prepares a string with the SASLprep profile of the stringprep algorithm. /// diff --git a/src/tables.rs b/src/tables.rs index 3eccb35..ecee304 100644 --- a/src/tables.rs +++ b/src/tables.rs @@ -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};