Skip to content

Commit

Permalink
Move CStr and CString out of "std" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dylni committed Feb 11, 2023
1 parent 869216d commit 21e3eec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 10 additions & 18 deletions src/quote.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use core::ffi::CStr;
use core::fmt;
use core::fmt::Write as _;

Expand Down Expand Up @@ -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<u8>);
impl_with_deref!(CString, String, Vec<u8>);
}

#[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",
Expand Down

0 comments on commit 21e3eec

Please sign in to comment.