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

Replicated-from: https://github.com/cloudflare/pingora/pull/100
Includes-commit: 15cffed202
This commit is contained in:
gengteng 2024-03-03 04:26:22 +00:00 committed by Yuchen Wu
parent ab86012c66
commit 558371c190
2 changed files with 3 additions and 2 deletions

2
.bleep
View file

@ -1 +1 @@
b1c09703606d32b02f24d2e77d82936ba95e8064
ff2f3fb1c3c2b52d92fd5ff3b76b6f4d25488fb2

View file

@ -175,7 +175,8 @@ impl Server {
///
/// Command line options can either be passed by parsing the command line arguments via
/// `Opt::from_args()`, or be generated by other means.
pub fn new(opt: Option<Opt>) -> Result<Server> {
pub fn new(opt: impl Into<Option<Opt>>) -> Result<Server> {
let opt = opt.into();
let (tx, rx) = watch::channel(false);
let conf = if let Some(opt) = opt.as_ref() {