在Scala中,我可以使用Option
作为从val threeOpt = Some(3)
val shouldBeThree = threeOpt.getOrElse(-1) // got 3
获取默认值的便捷方法,在Rust中这等效于什么?
echo str_replace( '__DUMMYSTRING__',$newHTMLCODE,$HTMLCodeFormDataBase);
在Scala中,我可以使用Option
作为从val threeOpt = Some(3)
val shouldBeThree = threeOpt.getOrElse(-1) // got 3
获取默认值的便捷方法,在Rust中这等效于什么?
echo str_replace( '__DUMMYSTRING__',$newHTMLCODE,$HTMLCodeFormDataBase);
您可以使用unwrap_or
或unwrap_or_else
unwrap_or
受到热切评价unwrap_or_else
被懒惰地评估