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

Replace nested if let with if let chain #472

Closed
bruingineer opened this issue May 7, 2024 · 2 comments
Closed

Replace nested if let with if let chain #472

bruingineer opened this issue May 7, 2024 · 2 comments
Labels
component: backend Rust/Tauri backend type: dev For dev environment, not product function

Comments

@bruingineer
Copy link
Collaborator

Tracking issue to address the todo comment below.
rust-lang/rust#53667

in main.rs, line 40, open_file_dialog(...)

// TODO: Replace with if-let chains (https://github.com/rust-lang/rfcs/pull/2497)
if let Some(path) = file_path {
    if let Some(dir) = path.parent() {
        if let Some(name) = path.file_name() {
            if let Ok(adjacent_gradle) = contains_build_gradle(Some(dir)).await {
                let _ = app_handle.emit_all(
                    "open-file",
                    OpenFileEventPayload {
                        dir: dir.as_os_str().to_str(),
                        name: name.to_str(),
                        contents: file::read_string(path.clone()).ok().as_deref(),
                        adjacent_gradle,
                    },
                );
            }
        }
    }
}
@spacey-sooty
Copy link
Collaborator

I think Rust 2024 edition should have support for this

@calcmogul calcmogul added type: dev For dev environment, not product function component: backend Rust/Tauri backend labels Jul 8, 2024
@shueja
Copy link
Collaborator

shueja commented Sep 24, 2024

After the big Rust refactor, we don't have any cases of if let where this would be useful

@shueja shueja closed this as completed Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: backend Rust/Tauri backend type: dev For dev environment, not product function
Projects
None yet
Development

No branches or pull requests

4 participants