-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(header): Implement find method on headers #350
Conversation
Add the ability in the Headers struct of types to be able to find a key and if found return the corresponding value.
Co-authored-by: Arpad Borsos <[email protected]>
Co-authored-by: Arpad Borsos <[email protected]>
assert_eq!(headers.get("key1"), Some(b"value1".to_vec()).as_deref()); | ||
assert_eq!(headers.get("key2"), Some(b"value2".to_vec()).as_deref()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert_eq!(headers.get("key1"), Some(b"value1".to_vec()).as_deref()); | |
assert_eq!(headers.get("key2"), Some(b"value2".to_vec()).as_deref()); | |
assert_eq!(headers.get("key1"), Some(b"value1")); | |
assert_eq!(headers.get("key2"), Some(b"value2")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested change gives the following error
error[E0308]: mismatched types
--> rust-arroyo/src/backends/kafka/types.rs:162:41
|
162 | assert_eq!(headers.get("key1"), Some(b"value1"));
| ^^^^^^^^^^^^^^^ expected Option<&[u8]>
, found Option<&[u8; 6]>
|
= note: expected enum Option<&[u8]>
found enum Option<&[u8; 6]>
error[E0308]: mismatched types
--> rust-arroyo/src/backends/kafka/types.rs:163:41
|
163 | assert_eq!(headers.get("key2"), Some(b"value2"));
| ^^^^^^^^^^^^^^^ expected Option<&[u8]>
, found Option<&[u8; 6]>
|
= note: expected enum Option<&[u8]>
found enum Option<&[u8; 6]>
Didn't know rust would be so restrictive. Made a change to map the value and return its ref.
Add the ability in the Headers struct of types to be able to find a key and if found return the corresponding value.