Skip to content

Code formatting for Rust Workers examples is off #23649

@samscott89

Description

@samscott89

Example URL(s)

https://developers.cloudflare.com/workers/examples/websockets/

Actual Behavior

This is the example from that page:

use worker::\*;

#[event(fetch)]
async fn fetch(req: HttpRequest, \_env: Env, \_ctx: Context) -> Result<worker::Response> {
let upgrade_header = match req.headers().get("Upgrade") {
Some(h) => h.to_str().unwrap(),
None => "",
};
if upgrade_header != "websocket" {
return worker::Response::error("Expected Upgrade: websocket", 426);
}
}

Issues:

  • Glob import has been escaped worker::\*
  • Variable underscore also has been escaped: \_env
  • Indentation all gone

Expected Behavior

It was correct prior to #21258

Additional information

Doing a git blame it looks like these were probably the result of an over-eager autoformatter in this PR:

#21258

Metadata

Metadata

Assignees

Labels

engineeringProblems or updates to developers.cloudflare.com website

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions