xso: fix no_std support
This reverts the Revert in 6ec275d3 which had to be done in order to
un-break usage of xso in std crates.
This commit is contained in:
parent
bf12accd48
commit
beae4ae66b
9 changed files with 42 additions and 9 deletions
|
|
@ -31,6 +31,7 @@ Version NEXT:
|
|||
the base64 crate (if the `base64` feature is enabled).
|
||||
- New `codec` field on `attribute` meta, to support decoding and
|
||||
encoding using any `TextCodec`.
|
||||
- Support for `no_std` usage (the alloc crate is required, though).
|
||||
|
||||
Version 0.1.2:
|
||||
2024-07-26 Jonas Schäfer <jonas@zombofant.net>
|
||||
|
|
|
|||
|
|
@ -45,6 +45,22 @@ pub mod exports {
|
|||
pub use minidom;
|
||||
pub use rxml;
|
||||
|
||||
// These re-exports are necessary to support both std and no_std in code
|
||||
// generated by the macros.
|
||||
//
|
||||
// If we attempted to use ::alloc directly from macros, std builds would
|
||||
// not work because alloc is not generally present in builds using std.
|
||||
// If we used ::std, no_std builds would obviously not work. By exporting
|
||||
// std as alloc in std builds, we can safely use the alloc types from
|
||||
// there.
|
||||
//
|
||||
// Obviously, we have to be careful in xso-proc to not refer to types
|
||||
// which are not in alloc.
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern crate alloc;
|
||||
#[cfg(feature = "std")]
|
||||
pub extern crate std as alloc;
|
||||
|
||||
/// The built-in `bool` type.
|
||||
///
|
||||
/// This is re-exported for use by macros in cases where we cannot rely on
|
||||
|
|
|
|||
Loading…
Reference in a new issue