Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Nov 22, 2023
1 parent 872e856 commit eeef4bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions core/src/ast/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ pub enum TypeName {
}

#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug, Copy)]
#[non_exhaustive]
pub enum StringEncoding {
UnvalidatedUtf8,
UnvalidatedUtf16,
Expand Down
19 changes: 13 additions & 6 deletions macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ fn cfgs_to_stream(attrs: &[Attribute]) -> proc_macro2::TokenStream {

fn gen_params_at_boundary(param: &ast::Param, expanded_params: &mut Vec<FnArg>) {
match &param.ty {
ast::TypeName::StrReference(..) | ast::TypeName::PrimitiveSlice(..) => {
ast::TypeName::StrReference(
..,
ast::StringEncoding::UnvalidatedUtf8 | ast::StringEncoding::UnvalidatedUtf16,
)
| ast::TypeName::PrimitiveSlice(..) => {
let data_type = if let ast::TypeName::PrimitiveSlice(.., prim) = &param.ty {
ast::TypeName::Primitive(*prim).to_syn().to_token_stream()
} else if let ast::TypeName::StrReference(_, e) = &param.ty {
match e {
ast::StringEncoding::UnvalidatedUtf8 => quote! { u8 },
ast::StringEncoding::UnvalidatedUtf16 => quote! { u16 },
}
} else if let ast::TypeName::StrReference(_, ast::StringEncoding::UnvalidatedUtf8) =
&param.ty
{
quote! { u8 }
} else if let ast::TypeName::StrReference(_, ast::StringEncoding::UnvalidatedUtf16) =
&param.ty
{
quote! { u16 }
} else {
unreachable!()
};
Expand Down

0 comments on commit eeef4bd

Please sign in to comment.