devela/text/str/
reexports.rs

1// devela::text::str:reexports
2//
3//! String related re-exports.
4//!
5//! Reexport the *const-str* crate macros related to string slices,
6//! prefixed with `str_` and with a new first line of documentation.
7//
8
9use crate::{impl_cdef, reexport};
10
11/* core */
12
13reexport! { rust: core::str,
14    doc: "Parse a value from a string.",
15    FromStr
16}
17
18/* alloc */
19
20reexport! { rust: alloc::string,
21    doc: "A UTF-8–encoded, growable string.",
22    String
23}
24reexport! { rust: alloc::string,
25    doc: "A trait for converting a value to a [`String`].",
26    ToString
27}
28
29/* std */
30
31reexport! { rust: std::ffi,
32    doc: "Borrowed reference to an OS string (See [`OsString`]).",
33    OsStr
34}
35reexport! { rust: std::ffi,
36    doc: "A type for owned, mutable native strings, interconvertible with Rust strings.",
37    OsString
38}
39
40/* from other modules */
41
42pub use crate::CStr;
43#[cfg(feature = "alloc")]
44pub use crate::CString;
45
46/* impl ConstDefault */
47
48impl_cdef!["" => &str];
49#[cfg(all(not(feature = "safe_text"), feature = "unsafe_str"))]
50#[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "unsafe_str")))]
51impl crate::ConstDefault for &mut str {
52    // SAFETY: The empty string is valid UTF-8.
53    const DEFAULT: Self = unsafe { ::core::str::from_utf8_unchecked_mut(&mut []) };
54}
55#[cfg(feature = "alloc")]
56impl_cdef![Self::new() => String];