Removed unnecessary String cloning

master
Jef Roosens 2021-04-05 11:00:41 +02:00
parent ea72231612
commit 8057f50f54
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
3 changed files with 5 additions and 6 deletions

View File

@ -1,4 +1,3 @@
use reqwest::Error;
use rocket::http::Status;
pub enum FejError {
@ -16,8 +15,8 @@ impl From<FejError> for Status {
}
// TODO make this more advanced where possible
impl From<Error> for FejError {
fn from(_: Error) -> FejError {
impl From<reqwest::Error> for FejError {
fn from(_: reqwest::Error) -> FejError {
FejError::FailedRequest
}
}

View File

@ -24,7 +24,7 @@ pub fn search_streets(street_name: &String) -> Result<Vec<Street>, FejError> {
// We iterate over every item and extract the needed data
for map in data.iter() {
if let Some(value) = map.get("value") {
match Street::try_from(value.clone()) {
match Street::try_from(value) {
Ok(street) => output.push(street),
Err(_) => continue,
}

View File

@ -28,10 +28,10 @@ impl Serialize for Street {
}
}
impl TryFrom<String> for Street {
impl TryFrom<&String> for Street {
type Error = ();
fn try_from(value: String) -> Result<Self, Self::Error> {
fn try_from(value: &String) -> Result<Self, Self::Error> {
if let Some(index) = value.find('(') {
Ok(Street {
name: (value[0..index - 1].trim()).to_string(),