Skip to content

Commit 811c354

Browse files
committed
Update to edition 2021
Rouille does not currently specify an edition. Set it to 2021 and update to newer idioms, including: * Remove unneeded `extern crate` * Remove `fn main() { /* ... */ }` in doctests * Replace `#[macro_use]` with direct imports
1 parent ea70dcc commit 811c354

30 files changed

+93
-147
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
name = "rouille"
33
version = "3.6.2"
44
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
5-
license = "MIT/Apache-2.0"
5+
license = "MIT OR Apache-2.0"
6+
edition = "2021"
67
repository = "https://github.com/tomaka/rouille"
78
documentation = "http://docs.rs/rouille"
89
description = "High-level idiomatic web framework."

examples/database.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,11 @@
77
// notice may not be copied, modified, or distributed except
88
// according to those terms.
99

10-
#[macro_use]
11-
extern crate rouille;
12-
extern crate postgres;
13-
extern crate serde;
14-
#[macro_use]
15-
extern crate serde_derive;
16-
1710
use std::sync::Mutex;
1811

1912
use postgres::{Client, NoTls, Transaction};
20-
13+
use rouille::router;
14+
use rouille::try_or_400;
2115
use rouille::Request;
2216
use rouille::Response;
2317

@@ -109,7 +103,7 @@ fn note_routes(request: &Request, db: &mut Transaction) -> Response {
109103
(GET) (/notes) => {
110104
// This route returns the list of notes. We perform the query and output it as JSON.
111105

112-
#[derive(Serialize)]
106+
#[derive(serde_derive::Serialize)]
113107
struct Elem { id: String }
114108

115109
let mut out = Vec::new();

examples/git-http-backend.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// notice may not be copied, modified, or distributed except
88
// according to those terms.
99

10-
extern crate rouille;
11-
1210
use rouille::cgi::CgiRun;
1311
use std::env;
1412
use std::io;

examples/hello-world.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// according to those terms.
99

1010
#![allow(unreachable_code)]
11-
#[macro_use]
12-
extern crate rouille;
1311

1412
fn main() {
1513
println!("Now listening on localhost:8000");
@@ -29,7 +27,7 @@ fn main() {
2927
// the `router!` macro is an expression whose value is the `Response` built by the block
3028
// that was called. Since `router!` is the last piece of code of this closure, the
3129
// `Response` is then passed back to the `start_server` function and sent to the client.
32-
router!(request,
30+
rouille::router!(request,
3331
(GET) (/) => {
3432
// If the request's URL is `/`, we jump here.
3533
// This block builds a `Response` object that redirects to the `/hello/world`.

examples/login-session.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#![allow(unreachable_code)]
2-
#[macro_use]
3-
extern crate rouille;
42

3+
use rouille::post_input;
4+
use rouille::router;
5+
use rouille::try_or_400;
56
use rouille::Request;
67
use rouille::Response;
78
use std::collections::HashMap;
@@ -95,7 +96,7 @@ fn main() {
9596
fn handle_route(request: &Request, session_data: &mut Option<SessionData>) -> Response {
9697
// First we handle the routes that are always accessible and always the same, no matter whether
9798
// the user is logged in or not.
98-
router!(request,
99+
rouille::router!(request,
99100
(POST) (/login) => {
100101
// This is the route that is called when the user wants to log in.
101102

examples/php.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// notice may not be copied, modified, or distributed except
88
// according to those terms.
99

10-
extern crate rouille;
11-
1210
use rouille::cgi::CgiRun;
1311
use std::process::Command;
1412

examples/reverse-proxy.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// notice may not be copied, modified, or distributed except
88
// according to those terms.
99

10-
extern crate rouille;
11-
1210
fn main() {
1311
// This example shows how to create a reverse proxy with rouille.
1412

examples/simple-form.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#[macro_use]
2-
extern crate rouille;
3-
41
use std::io;
52

3+
use rouille::post_input;
4+
use rouille::router;
5+
use rouille::try_or_400;
6+
67
fn main() {
78
// This example demonstrates how to handle HTML forms.
89

examples/static-files.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// notice may not be copied, modified, or distributed except
88
// according to those terms.
99

10-
extern crate rouille;
11-
1210
use rouille::Response;
1311

1412
fn main() {

examples/websocket.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
// notice may not be copied, modified, or distributed except
88
// according to those terms.
99

10-
#[macro_use]
11-
extern crate rouille;
12-
1310
use std::thread;
1411

12+
use rouille::router;
13+
use rouille::try_or_400;
1514
use rouille::websocket;
1615
use rouille::Response;
1716

0 commit comments

Comments
 (0)