Skip to content

Commit

Permalink
Clippy refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Shell1010 committed Jan 21, 2024
1 parent 41bafa5 commit 83343e2
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions lines/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Client {
fn modify_endpoint(mut self, endpoint: &str) -> Self {
self.url = None;
self.url = Some(endpoint.to_string());
return self
self
}

pub fn version(self) -> Self {
Expand Down Expand Up @@ -72,19 +72,17 @@ impl Client {
// return Ok(from_str(&text).unwrap())
if let Ok(real_data) = from_str::<Value>(&text) {

match real_data {

Value::Array(_) => {
if real_data[0]["$type"] == "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities" {
for data in real_data.as_array().unwrap() {
let data: Result<LineRoute, serde_json::Error> = from_value(data.to_owned());
if let Ok(data) = data {
return Ok(DataStruct::from(data))
}
if let Value::Array(_) = real_data {

if real_data[0]["$type"] == "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities" {
for data in real_data.as_array().unwrap() {
let data: Result<LineRoute, serde_json::Error> = from_value(data.to_owned());
if let Ok(data) = data {
return Ok(DataStruct::from(data))
}
}
},
_ => (),
}

}

match &real_data["$type"] {
Expand Down Expand Up @@ -124,7 +122,7 @@ impl Client {
Err(e) => return Err(TflError::HttpError(e))
}
}
return Err(TflError::ApiError("Url was not instantiated".to_string()))
Err(TflError::ApiError("Url was not instantiated".to_string()))
}

}
Expand Down

0 comments on commit 83343e2

Please sign in to comment.