ZhangZhihui's Blog  

 

 

Here, WithPort returns a closure. A closure is an anonymous function that references variables from outside its body; in this case, the port variable. The closure respects the Option type and implements the port-validation logic. Each config field requires creating a public function (that starts with the With prefix by convention) containing similar logic: validating inputs if needed and updating the config struct.

 

 

 

posted on 2024-02-14 11:45  ZhangZhihuiAAA  阅读(6)  评论(0编辑  收藏  举报