From 21e3eec4f94d33a7863963fd02d1c410d5569d10 Mon Sep 17 00:00:00 2001 From: dylni <46035563+dylni@users.noreply.github.com> Date: Sat, 11 Feb 2023 09:29:53 -0500 Subject: [PATCH] Move `CStr` and `CString` out of "std" feature --- .github/workflows/build.yml | 4 ++-- Cargo.toml | 2 +- README.md | 2 +- src/quote.rs | 28 ++++++++++------------------ 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd68ca4..2ccc2de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: target: [wasm32-wasi, x86_64-unknown-redox] - version: [1.56.0, stable, beta, nightly] + version: [1.64.0, stable, beta, nightly] include: - target: x86_64-fortanix-unknown-sgx version: nightly @@ -44,4 +44,4 @@ jobs: strategy: matrix: platform: [macos-latest, ubuntu-latest, windows-latest] - version: [1.56.0, stable, beta, nightly] + version: [1.64.0, stable, beta, nightly] diff --git a/Cargo.toml b/Cargo.toml index a9ee8ec..14877c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "uniquote" version = "3.2.1" authors = ["dylni"] edition = "2021" -rust-version = "1.56.0" +rust-version = "1.64.0" description = """ Quote strings for clear display in output """ diff --git a/README.md b/README.md index bb2e666..bce9cf5 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ See the [documentation] for available functionality and examples. ## Rust version support -The minimum supported Rust toolchain version is currently Rust 1.56.0. +The minimum supported Rust toolchain version is currently Rust 1.64.0. Minor version updates may increase this version requirement. However, the previous two Rust releases will always be supported. If the minimum Rust diff --git a/src/quote.rs b/src/quote.rs index 1308bed..617a34f 100644 --- a/src/quote.rs +++ b/src/quote.rs @@ -1,3 +1,4 @@ +use core::ffi::CStr; use core::fmt; use core::fmt::Write as _; @@ -128,33 +129,24 @@ macro_rules! impl_with_deref { }; } +impl Quote for CStr { + #[inline] + fn escape(&self, f: &mut Formatter<'_>) -> Result { + self.to_bytes().escape(f) + } +} + #[cfg(feature = "alloc")] mod alloc { + use alloc::ffi::CString; use alloc::string::String; use alloc::vec::Vec; - impl_with_deref!(String, Vec); + impl_with_deref!(CString, String, Vec); } #[cfg(feature = "std")] mod std { - use std::ffi::CStr; - use std::ffi::CString; - - use crate::Formatter; - use crate::Result; - - use super::Quote; - - impl Quote for CStr { - #[inline] - fn escape(&self, f: &mut Formatter<'_>) -> Result { - self.to_bytes().escape(f) - } - } - - impl_with_deref!(CString); - #[cfg(any( all(target_vendor = "fortanix", target_env = "sgx"), target_os = "hermit",