deltanedas 3 semanas atrás
pai
commit
7df4293cd2
4 arquivos alterados com 22 adições e 5 exclusões
  1. 1 1
      Cargo.toml
  2. 1 1
      orio-derive/Cargo.toml
  3. 3 3
      orio-derive/src/lib.rs
  4. 17 0
      src/tests.rs

+ 1 - 1
Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "orio"
-version = "0.7.1"
+version = "0.7.2"
 authors = ["deltanedas"]
 edition = "2024"
 rust-version = "1.85"

+ 1 - 1
orio-derive/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "orio-derive"
-version = "0.7.1"
+version = "0.7.2"
 authors = ["deltanedas"]
 edition = "2024"
 readme = "README.md"

+ 3 - 3
orio-derive/src/lib.rs

@@ -79,7 +79,7 @@ fn derive_io_inner(ident: Ident, data: Data) -> TokenStream2 {
 					let variant = #variant_type::read(r)?;
 					match variant {
 						#(#read_variants)*
-						_ => return Err(derive_enum_variant_error(variant.into(), stringify!(#ident)))
+						_ => return ::std::io::Result::Err(derive_enum_variant_error(variant.into(), stringify!(#ident)))
 					}
 				}
 			}, quote! {
@@ -105,12 +105,12 @@ fn derive_io_inner(ident: Ident, data: Data) -> TokenStream2 {
 		#[automatically_derived]
 		impl Io for #ident {
 			fn read(r: &mut Reader) -> ::std::io::Result<Self> {
-				Ok(#read)
+				::std::io::Result::Ok(#read)
 			}
 
 			fn write(&self, w: &mut Writer) -> ::std::io::Result<()> {
 				#write
-				Ok(())
+				::std::io::Result::Ok(())
 			}
 
 			fn size(&self) -> usize {

+ 17 - 0
src/tests.rs

@@ -387,3 +387,20 @@ fn array_slice() -> Result<()> {
 
 	Ok(())
 }
+
+// The derive macro can't break if a non-std Result, Ok or Err are in scope
+#[expect(unused)]
+mod inner {
+	use crate::*;
+
+	enum Result {
+		Ok(()),
+		Err(())
+	}
+
+	struct Ok(());
+	struct Err(());
+
+	#[derive(Io)]
+	struct Name(#[io(len(u8))] String);
+}