Skip to content

less verbose way to get base_url from env::args #20

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

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

vbauerster
Copy link
Contributor

That's a matter of taste, but imho it's a more idiomatic way to get single positional arg.

Following is just for history, if one don't want to allocate "localhost" on the heap. However using Cow in the context of this example is a bit of overkill.

let base_url = env::args().nth(1).map_or(Cow::from("localhost"), Cow::from);

@cfsamson
Copy link
Collaborator

Thanks, this change was a result of pr #19 to make it work with docker for Mac users. I agree that the shorter the better 👍

@cfsamson cfsamson merged commit cc627d4 into PacktPublishing:main Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants