Skip to content

Commit

Permalink
Add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky committed Jul 18, 2021
1 parent 41b16ec commit fb424b8
Show file tree
Hide file tree
Showing 13 changed files with 670 additions and 355 deletions.
4 changes: 3 additions & 1 deletion macros/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ pub fn derive_enum_impl(

}
} else {
let error = crate::CHOICE_ERROR_MESSAGE;

quote! {
Err(#crate_root::de::Error::custom("`CHOICE`-style enums cannot be implicitly tagged."))
Err(#crate_root::de::Error::custom(#error))
}
};

Expand Down
3 changes: 2 additions & 1 deletion macros/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ pub fn derive_enum_impl(
encoder.encode_enumerated(tag, *self as isize).map(drop)
}
} else {
let error = crate::CHOICE_ERROR_MESSAGE;
quote! {
Err::<(), _>(#crate_root::enc::Error::custom("CHOICE-style enums do not allow implicit tagging."))
Err::<(), _>(#crate_root::enc::Error::custom(#error))
}
};

Expand Down
1 change: 1 addition & 0 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod tag;
use config::Config;

const CRATE_NAME: &str = "rasn";
const CHOICE_ERROR_MESSAGE: &str = "CHOICE-style enums do not allow implicit tagging. If using the derive macro on a sequence with a choice field ensure it is marked with `#[rasn(choice)]`.";

/// Helper function print out the derive.
fn __print_stream(stream: proc_macro2::TokenStream) -> proc_macro::TokenStream {
Expand Down
Loading

0 comments on commit fb424b8

Please sign in to comment.