Removed unnecessary String cloning
parent
ea72231612
commit
8057f50f54
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in New Issue