diff --git a/src/lib.rs b/src/lib.rs index 8c92e51..6712dfc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![no_std] +#![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; use alloc::{ @@ -310,6 +310,13 @@ impl Borrow for SmolStr { } } +#[cfg(feature = "std")] +impl AsRef for SmolStr { + fn as_ref(&self) -> &std::ffi::OsStr { + (&**self).as_ref() + } +} + impl FromStr for SmolStr { type Err = Infallible;