Curl example doesn't compile : method not found in `Option<&NgxStr>`
mtb0x1 opened this issue · 0 comments
mtb0x1 commented
Describe the bug
I can't compile curl example, error message :
error[E0599]: no method named `as_bytes` found for enum `Option` in the current scope
--> examples/curl.rs:114:37
|
114 | if request.user_agent().as_bytes().starts_with(b"curl") {
| ^^^^^^^^ method not found in `Option<&NgxStr>`
|
note: the method `as_bytes` exists on the type `&NgxStr`
--> /home/user/apps/rust/ngx-rust/src/core/string.rs:55:5
|
55 | pub fn as_bytes(&self) -> &[u8] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider using `Option::expect` to unwrap the `&NgxStr` value, panicking if the value is an `Option::None`
|
114 | if request.user_agent().expect("REASON").as_bytes().starts_with(b"curl") {
| +++++++++++++++++
For more information about this error, try `rustc --explain E0599`.
error: could not compile `examples` (example "curl") due to previous error
To Reproduce
Steps to reproduce the behavior:
- Run
cargo build --release --package=examples --example=curl
- See error
Expected behavior
Curl example compiles without errors
Your environment
- Repo version : Last version up to date (9ce7895)
- Version of Rust : stable, rustc 1.73.0 (cc66ad468 2023-10-03)
- OS and distribution : Debian bookworm
Additional context
N/A