Skip to content

Commit

Permalink
eliminate some clippy warnings for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannavl committed May 14, 2019
1 parent 358db73 commit 36f5954
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/src/body_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async fn echo_form(mut cx: Context<()>) -> EndpointResult {
Ok(forms::form(msg))
}

fn main() {
pub fn main() {
let mut app = App::new();

app.at("/echo/string").post(echo_string);
Expand Down
2 changes: 1 addition & 1 deletion examples/src/catch_all.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tide::Context;

pub async fn echo_path(cx: Context<()>) -> String {
async fn echo_path(cx: Context<()>) -> String {
let path: String = cx.param("path").unwrap();
format!("Your path is: {}", path)
}
Expand Down
3 changes: 1 addition & 2 deletions examples/src/cookies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use cookie::Cookie;
use tide::{cookies::CookiesExt, middleware::CookiesMiddleware, Context};

/// Tide will use the the `Cookies`'s `Extract` implementation to build this parameter.
///
async fn retrieve_cookie(mut cx: Context<()>) -> String {
format!("hello cookies: {:?}", cx.get_cookie("hello").unwrap())
}
Expand All @@ -17,7 +16,7 @@ async fn remove_cookie(mut cx: Context<()>) {
cx.remove_cookie(Cookie::named("hello")).unwrap();
}

fn main() {
pub fn main() {
let mut app = tide::App::new();
app.middleware(CookiesMiddleware::new());

Expand Down
2 changes: 1 addition & 1 deletion examples/src/default_headers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tide::middleware::DefaultHeaders;

fn main() {
pub fn main() {
let mut app = tide::App::new();

app.middleware(
Expand Down
2 changes: 1 addition & 1 deletion examples/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async fn handle_graphql(mut cx: Context<Data>) -> EndpointResult {
Ok(resp)
}

fn main() {
pub fn main() {
let mut app = App::with_state(Data::default());
app.at("/graphql").post(handle_graphql);
app.serve("127.0.0.1:8000").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/src/hello.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main() {
pub fn main() {
let mut app = tide::App::new();
app.at("/").get(async move |_| "Hello, world!");
app.serve("127.0.0.1:8000").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(async_await)]
#![allow(unused)]
#![warn(clippy::all)]
#![allow(dead_code)]

mod body_types;
mod catch_all;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async fn get_message(cx: Context<Database>) -> EndpointResult {
}
}

fn main() {
pub fn main() {
let mut app = App::with_state(Database::default());
app.at("/message").post(new_message);
app.at("/message/:id").get(get_message).post(set_message);
Expand Down
4 changes: 2 additions & 2 deletions examples/src/staticfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl StaticFile {
// Check if the path exists and handle if it's a directory containing `index.html`
if meta.is_some() && meta.as_ref().map(|m| !m.is_file()).unwrap_or(false) {
// Redirect if path is a dir and URL doesn't end with "/"
if !actual_path.ends_with("/") {
if !actual_path.ends_with('/') {
return Ok(response
.status(StatusCode::MOVED_PERMANENTLY)
.header(header::LOCATION, String::from(actual_path) + "/")
Expand Down Expand Up @@ -119,7 +119,7 @@ async fn handle_path(ctx: Context<StaticFile>) -> EndpointResult {
})
}

fn main() {
pub fn main() {
let mut app = App::with_state(StaticFile::new("./"));
app.at("/*").get(handle_path);
app.serve("127.0.0.1:8000").unwrap();
Expand Down

0 comments on commit 36f5954

Please sign in to comment.