rustfmt and removal of superfluous constant

master
CptCaptain 3 years ago
parent 58c52e4033
commit 004887799e
  1. 19
      src/main.rs

@ -7,8 +7,8 @@ use std::env;
use std::fmt; use std::fmt;
use std::path::Path; use std::path::Path;
use rocket::request::FromFormValue;
use rocket::http::RawStr; use rocket::http::RawStr;
use rocket::request::FromFormValue;
use rocket::http::uri::Absolute; use rocket::http::uri::Absolute;
use rocket::request::Form; use rocket::request::Form;
@ -18,9 +18,9 @@ use std::process::Command;
#[derive(Debug)] #[derive(Debug)]
struct Link { struct Link {
uri: String uri: String,
} }
#[derive(FromForm)] #[derive(FromForm)]
struct Video { struct Video {
link: Link, link: Link,
@ -31,8 +31,8 @@ const LIMIT: u64 = 1024;
impl fmt::Display for Link { impl fmt::Display for Link {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.uri) write!(f, "{}", self.uri)
} }
} }
impl<'v> FromFormValue<'v> for Link { impl<'v> FromFormValue<'v> for Link {
@ -42,7 +42,7 @@ impl<'v> FromFormValue<'v> for Link {
// Decode form data into string // Decode form data into string
let string = match form_value.url_decode() { let string = match form_value.url_decode() {
Ok(string) => string, Ok(string) => string,
Err(_) => return Err(form_value) Err(_) => return Err(form_value),
}; };
// Try to parse a hyperlink from the string // Try to parse a hyperlink from the string
@ -58,8 +58,10 @@ impl<'v> FromFormValue<'v> for Link {
// Check for success // Check for success
let result = match abs_uri { let result = match abs_uri {
Some(abs_uri) => Link{uri: abs_uri.to_string()}, Some(abs_uri) => Link {
_ => return Err(form_value) uri: abs_uri.to_string(),
},
_ => return Err(form_value),
}; };
// Return successfully. // Return successfully.
@ -67,7 +69,6 @@ impl<'v> FromFormValue<'v> for Link {
} }
} }
#[post("/new", data = "<video>")] #[post("/new", data = "<video>")]
fn new(video: Form<Video>) -> Redirect { fn new(video: Form<Video>) -> Redirect {
Command::new("/bin/env") Command::new("/bin/env")

Loading…
Cancel
Save