Revert "xso-proc: Replace std stuff with alloc/core stuff"

Jonas SchΓ€fer created

This reverts commit 4e5f0bc9615f075f1bd2094f200cdc5e37ea1976.

Unfortunately, in std contexts, the `alloc` crate is not imported. That
means we cannot rely on it being accessible and it in fact breaks builds
of crates which are not `no_std`.

Fixes #155.

Change summary

xso-proc/src/enums.rs           | 2 +-
xso-proc/src/field/attribute.rs | 2 +-
xso-proc/src/field/child.rs     | 2 +-
xso-proc/src/field/text.rs      | 2 +-
xso-proc/src/lib.rs             | 2 --
xso-proc/src/structs.rs         | 2 +-
xso-proc/src/types.rs           | 6 +++---
xso/src/from_xml_doc.md         | 2 --
8 files changed, 8 insertions(+), 12 deletions(-)

Detailed changes

xso-proc/src/enums.rs πŸ”—

@@ -140,7 +140,7 @@ impl NameVariant {
                 quote! {
                     let name = (
                         ::xso::exports::rxml::Namespace::from(#xml_namespace),
-                        ::alloc::borrow::Cow::Borrowed(#xml_name),
+                        ::std::borrow::Cow::Borrowed(#xml_name),
                     );
                     #init
                 }

xso-proc/src/field/attribute.rs πŸ”—

@@ -102,7 +102,7 @@ impl Field for AttributeField {
             generator: quote! {
                 #as_optional_xml_text(#bound_name)?.map(|#bound_name| ::xso::Item::Attribute(
                     #xml_namespace,
-                    ::alloc::borrow::Cow::Borrowed(#xml_name),
+                    ::std::borrow::Cow::Borrowed(#xml_name),
                     #bound_name,
                 ));
             },

xso-proc/src/field/child.rs πŸ”—

@@ -423,7 +423,7 @@ impl ExtractDef {
                 quote! {
                     let name = (
                         ::xso::exports::rxml::Namespace::from(#xml_namespace),
-                        ::alloc::borrow::Cow::Borrowed(#xml_name),
+                        ::std::borrow::Cow::Borrowed(#xml_name),
                     );
                     #init
                 }

xso-proc/src/field/text.rs πŸ”—

@@ -51,7 +51,7 @@ impl Field for TextField {
 
         Ok(FieldBuilderPart::Text {
             value: FieldTempInit {
-                init: quote! { ::alloc::string::String::new() },
+                init: quote! { ::std::string::String::new() },
                 ty: string_ty(Span::call_site()),
             },
             collect: quote! {

xso-proc/src/lib.rs πŸ”—

@@ -18,8 +18,6 @@ return to `xso` for more information**. The documentation of
 **You have been warned.**
 */
 
-extern crate alloc;
-
 // Wondering about RawTokenStream vs. TokenStream?
 // syn mostly works with proc_macro2, while the proc macros themselves use
 // proc_macro.

xso-proc/src/structs.rs πŸ”—

@@ -294,7 +294,7 @@ impl StructInner {
                     quote! {
                         let name = (
                             ::xso::exports::rxml::Namespace::from(#xml_namespace),
-                            ::alloc::borrow::Cow::Borrowed(#xml_name),
+                            ::std::borrow::Cow::Borrowed(#xml_name),
                         );
                         #init
                     }

xso-proc/src/types.rs πŸ”—

@@ -84,7 +84,7 @@ pub(crate) fn cow_ty(ty: Type, lifetime: Lifetime) -> Type {
             }),
             segments: [
                 PathSegment {
-                    ident: Ident::new("alloc", span),
+                    ident: Ident::new("std", span),
                     arguments: PathArguments::None,
                 },
                 PathSegment {
@@ -233,7 +233,7 @@ pub(crate) fn default_fn(of_ty: Type) -> Expr {
     })
 }
 
-/// Construct a [`syn::Type`] referring to `::alloc::string::String`.
+/// Construct a [`syn::Type`] referring to `::std::string::String`.
 pub(crate) fn string_ty(span: Span) -> Type {
     Type::Path(TypePath {
         qself: None,
@@ -243,7 +243,7 @@ pub(crate) fn string_ty(span: Span) -> Type {
             }),
             segments: [
                 PathSegment {
-                    ident: Ident::new("alloc", span),
+                    ident: Ident::new("std", span),
                     arguments: PathArguments::None,
                 },
                 PathSegment {

xso/src/from_xml_doc.md πŸ”—

@@ -588,7 +588,6 @@ a field, for consistency.
 #### Example without codec
 
 ```rust
-# extern crate alloc;
 # use xso::FromXml;
 #[derive(FromXml, Debug, PartialEq)]
 #[xml(namespace = "urn:example", name = "foo")]
@@ -606,7 +605,6 @@ assert_eq!(foo, Foo {
 #### Example with codec
 
 ```rust
-# extern crate alloc;
 # use xso::FromXml;
 #[derive(FromXml, Debug, PartialEq)]
 #[xml(namespace = "urn:example", name = "foo")]