Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ergonomic upgrades for skip parameters #30

Closed
zeon256 opened this issue May 1, 2022 · 0 comments
Closed

Ergonomic upgrades for skip parameters #30

zeon256 opened this issue May 1, 2022 · 0 comments

Comments

@zeon256
Copy link
Member

zeon256 commented May 1, 2022

Instead of taking Option<u32> in this case

async fn get_taxi_avail(client: &LTAClient, skip: Option<u32>) -> LTAResult<Vec<Coordinates>> {
    build_req_with_skip::<TaxiAvailResp, _, _>(client, api_url!("/Taxi-Availability"), skip).await
}

We can change the skip to impl Into<Option<u32>>.

async fn get_taxi_avail(client: &LTAClient, skip: impl Into<Option<u32>>) -> LTAResult<Vec<Coordinates>> {
    build_req_with_skip::<TaxiAvailResp, _, _>(client, api_url!("/Taxi-Availability"), skip).await
}

This allows you to call it like this.

let _ = get_taxi_avail(&client, 500);
let _ = get_taxi_avail(&client, None);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant