pingora icon indicating copy to clipboard operation
pingora copied to clipboard

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

Open gengteng opened this issue 1 year ago • 0 comments

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 avatar Mar 03 '24 04:03 gengteng