Skip to content
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

Curl example doesn't compile : method not found in Option<&NgxStr> #50

Closed
mtb0x1 opened this issue Oct 25, 2023 · 0 comments
Closed

Curl example doesn't compile : method not found in Option<&NgxStr> #50

mtb0x1 opened this issue Oct 25, 2023 · 0 comments

Comments

@mtb0x1
Copy link
Contributor

mtb0x1 commented Oct 25, 2023

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:

  1. Run cargo build --release --package=examples --example=curl
  2. 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

mtb0x1 added a commit to mtb0x1/ngx-rust that referenced this issue Oct 25, 2023
@mtb0x1 mtb0x1 mentioned this issue Oct 25, 2023
7 tasks
mtb0x1 added a commit to mtb0x1/ngx-rust that referenced this issue Oct 26, 2023
@mtb0x1 mtb0x1 closed this as completed Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant