cloudflare / pingora

A library for building fast, reliable and evolvable network services.
Apache License 2.0
21.42k stars 1.18k forks source link

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

Closed gengteng closed 6 months ago

gengteng commented 7 months ago

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:

let my_server = Server::new(Some(Opt::from_args())).unwrap();
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.

eaufavor commented 6 months ago

Merged via https://github.com/cloudflare/pingora/commit/558371c190b086e16942de622d9d3a68d30b4b4f