Skip to content

Commit

Permalink
Not equals for strings and bytes (#104)
Browse files Browse the repository at this point in the history
Implement support for != for string and byte value types. When used with bytes, the value on the LHS of the operator could be of type string or byte.
  • Loading branch information
diana-qing authored Mar 4, 2025
1 parent 139eabc commit 1e28e58
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions filtergen/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ pub(crate) fn binary_to_tokens(
let val_lit = syn::LitStr::new(text, Span::call_site());
quote! { #proto.#field() == #val_lit }
}
BinOp::Ne => {
let val_lit = syn::LitStr::new(text, Span::call_site());
quote! { #proto.#field() != #val_lit }
}
BinOp::En => {
let field_ident =
Ident::new(&field.to_string().to_camel_case(), Span::call_site());
Expand Down Expand Up @@ -194,6 +198,12 @@ pub(crate) fn binary_to_tokens(
#proto.#field().as_bytes() == #bytes_lit
}
}
BinOp::Ne => {
let bytes_lit = syn::LitByteStr::new(b, Span::call_site());
quote! {
#proto.#field().as_ref() as &[u8] != #bytes_lit
}
}
BinOp::Contains => {
let bytes_lit = syn::LitByteStr::new(b, Span::call_site());

Expand Down

0 comments on commit 1e28e58

Please sign in to comment.