Skip to content

Commit db2546b

Browse files
committed
fix: restrict String usage only in std
1 parent 775923b commit db2546b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/core/string.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
use core::slice;
22
use core::str::{self, Utf8Error};
33

4-
#[cfg(all(not(feature = "std"), feature = "alloc"))]
5-
use alloc::{borrow::Cow, string::String};
6-
#[cfg(feature = "std")]
7-
use std::{borrow::Cow, string::String};
8-
94
use crate::ffi::*;
105

116
/// Static string initializer for [`ngx_str_t`].
@@ -68,9 +63,11 @@ impl NgxStr {
6863
/// Converts an [`NgxStr`] into a [`Cow<str>`], replacing invalid UTF-8 sequences.
6964
///
7065
/// See [`String::from_utf8_lossy`].
71-
#[cfg(feature = "alloc")]
72-
pub fn to_string_lossy(&self) -> Cow<str> {
73-
String::from_utf8_lossy(self.as_bytes())
66+
///
67+
/// This module is temporally available only with `std` feature.
68+
#[cfg(feature = "std")]
69+
pub fn to_string_lossy(&self) -> std::borrow::Cow<str> {
70+
std::string::String::from_utf8_lossy(self.as_bytes())
7471
}
7572

7673
/// Returns `true` if the [`NgxStr`] is empty, otherwise `false`.

0 commit comments

Comments
 (0)