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

feat: Enhance Server::new to accept impl Into<Option<Opt>> for ergonomics #100

Closed
wants to merge 1 commit into from

Conversation

gengteng
Copy link
Contributor

@gengteng gengteng commented Mar 3, 2024

This PR simplifies the Server::new function interface by allowing direct passing of Opt or None without the need to wrap with Some. This enhancement makes the API more ergonomic and user-friendly.

Changes:

  • Before: Required to wrap Opt with Some.
let my_server = Server::new(Some(Opt::from_args())).unwrap();
  • After: Direct passing of Opt or None.
let my_server = Server::new(Opt::from_args()).unwrap();
let my_server = Server::new(None).unwrap();

// The previous method of wrapping `Opt` with `Some` is still supported.
let my_server = Server::new(Some(Opt::from_args())).unwrap();

This update streamlines function calls, improving the overall developer experience.

@gengteng gengteng force-pushed the option-into-ergonomics branch from 5b5f726 to 15cffed Compare March 4, 2024 09:31
@andrewhavck andrewhavck added the enhancement New feature or request label Mar 4, 2024
Copy link
Contributor

@drcaramelsyrup drcaramelsyrup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! For a very commonly used public API, this makes sense, LGTM.

@drcaramelsyrup drcaramelsyrup added the Accepted This change is accepted by us and merged to our internal repo label Mar 12, 2024
eaufavor pushed a commit that referenced this pull request Mar 22, 2024
eaufavor pushed a commit that referenced this pull request Mar 22, 2024
@eaufavor
Copy link
Member

Merged via 558371c

@eaufavor eaufavor closed this Mar 22, 2024
@gengteng gengteng deleted the option-into-ergonomics branch March 23, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted This change is accepted by us and merged to our internal repo enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants