Skip to content

deref on Box<str> #7

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

Open
AlbertMarashi opened this issue Feb 4, 2022 · 2 comments
Open

deref on Box<str> #7

AlbertMarashi opened this issue Feb 4, 2022 · 2 comments

Comments

@AlbertMarashi
Copy link

AlbertMarashi commented Feb 4, 2022

reposted:

I have this code, it does not compile. I am trying to deeply match a Box inside of a pattern, but the error is:

expected str, found `&str`

but there's no good way to match Box in a deeply nested pattern...

#![feature(box_patterns)]
struct Type {
    pub name: Box<str>,
    pub generics: Option<Vec<Type>>
}

fn main(){
    let kind = Type {
        name: "User".into(),
        generics: Some(Vec::new())
    };

    match kind {
        Type {
            name: box "User",
            generics
        } => {}
        _ => unimplemented!()
    }
}

Is there any kind of proposal to address the deref for this specific case?

@AlbertMarashi AlbertMarashi changed the title deref on Box<str> deref on Box<str> Feb 4, 2022
@AlbertMarashi AlbertMarashi changed the title deref on Box<str> deref on Box<str> Feb 4, 2022
@chorman0773
Copy link

Box is planned to be covered by the initial version of deref patterns, regardless of the inner type.

@AlbertMarashi
Copy link
Author

Great to hear. Can't wait for this feature. Any idea as to how long this process usually takes?

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