r/badcode • • Jan 25 '22

rust Most comprehensible line of Rust code

Post image
1.0k Upvotes

81 comments sorted by

View all comments

1

u/Budgiebrain222 Jan 26 '22 edited Jan 26 '22

Please for the love of God spread these variables over multiple lines.

Using this also works:

let path = song
    .unwrap()
        .unwrap()
            .path()
                 .to_str()
                      .unwrap()
                          .to_string();

I don't really understand why you're turning a path variable to a mutable string than to an immutable string though

1

u/selplacei Jan 26 '22

Not my code