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::{TAG_TEXT, impl_cdef, reexport};
10
11/* core */
12
13reexport! { rust: core::str,
14    tag: TAG_TEXT!(),
15    doc: "Parse a value from a string.",
16    FromStr
17}
18
19/* alloc */
20
21reexport! { rust: alloc::string,
22    tag: TAG_TEXT!(),
23    doc: "A UTF-8–encoded, growable string.",
24    String
25}
26reexport! { rust: alloc::string,
27    tag: TAG_TEXT!(),
28    doc: "A trait for converting a value to a [`String`].",
29    ToString
30}
31
32/* std */
33
34reexport! { rust: std::ffi,
35    tag: TAG_TEXT!(),
36    doc: "Borrowed reference to an OS string (See [`OsString`]).",
37    OsStr
38}
39reexport! { rust: std::ffi,
40    tag: TAG_TEXT!(),
41    doc: "A type for owned, mutable native strings, interconvertible with Rust strings.",
42    OsString
43}
44
45/* from other modules */
46
47pub use crate::CStr;
48#[cfg(feature = "alloc")]
49pub use crate::CString;
50
51/* impl ConstDefault */
52
53impl_cdef!["" => &str];
54#[cfg(all(not(feature = "safe_text"), feature = "unsafe_str"))]
55#[cfg_attr(nightly_doc, doc(cfg(feature = "unsafe_str")))]
56impl crate::ConstDefault for &mut str {
57    // SAFETY: The empty string is valid UTF-8.
58    const DEFAULT: Self = unsafe { ::core::str::from_utf8_unchecked_mut(&mut []) };
59}
60#[cfg(feature = "alloc")]
61impl_cdef![Self::new() => String];