How to convert a raw pointer, which can be null, into an Option?

后端 未结 0 1091
醉酒成梦
醉酒成梦 2020-12-04 20:39

I wrote the following macro:

macro_rules! ptr_to_opt {
    ($p: expr) => {
        if $p.is_null() {
            None
        } else {
            Some($p)         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题