debug-ignore icon indicating copy to clipboard operation
debug-ignore copied to clipboard

Add From to easier create the wrapped object

Open pravic opened this issue 3 years ago • 1 comments

Currently:

#[derive(Debug)]
pub struct PublicStruct {
    inner: DebugIgnore<InnerStructWithLotsOfDebugInfo>,
}

impl PublicStruct {
    pub fn new() -> Self {
        Self {
            inner: DebugIgnore(InnerStructWithLotsOfDebugInfo { field: "field", /* ... */ })
        }
    }
}

If From is implemented, it will allow to call .into(), similar to what Option has:

impl PublicStruct {
    pub fn new() -> Self {
        Self {
-            inner: DebugIgnore(InnerStructWithLotsOfDebugInfo { field: "field", /* ... */ })
+            inner: InnerStructWithLotsOfDebugInfo { field: "field", /* ... */ }.into()
        }
    }
}

pravic avatar Oct 02 '22 20:10 pravic

Sounds good! Would you like to submit a patch? Should be pretty simple.

sunshowers avatar Oct 02 '22 20:10 sunshowers