Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add From to easier create the wrapped object #3

Closed
pravic opened this issue Oct 2, 2022 · 1 comment
Closed

Add From to easier create the wrapped object #3

pravic opened this issue Oct 2, 2022 · 1 comment

Comments

@pravic
Copy link

pravic commented Oct 2, 2022

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()
        }
    }
}
@sunshowers
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants