原书出处
Write Powerful Rust Macros
07 From panic to result: Error handling 重写函数的返回值
Let’s get back to the task at hand: a macro that replaces panics with results. Let’s do this step by step. First, we will make our function return a Result. For the error type, we will go with a simple String. The value will have to match the current return type of the function. Once we have changed the signature, the final expression—currently returning a Person—will have to be wrapped in an Ok.
We will ignore more complex situations with
原书定位详情
来源:a19c7933-4eda-4176-aebd-30fe7e1ad292
正文位置:extracted/Write Powerful Rust Macros/_epub-src/OEBPS/Text/chapter-7.xhtml#p77
EPUB SHA-256:68c7ed23324b44144895c3bb55f55731454da237867b66ec66ca6404f5b93661