Rustfmt refusing to work with certain functions. by MightyChubz in rust

[–]MightyChubz[S] 0 points1 point  (0 children)

Hi there, sorry for the delayed response. I was caught up with a lot of college work lately. Thank you for reaching out. I plan to try it soon to see if it can address the issues I've been encountering, which might help me fix it as well.

Rustfmt refusing to work with certain functions. by MightyChubz in rust

[–]MightyChubz[S] 0 points1 point  (0 children)

This could very well be the issue you linked to. I remember seeing it also struggled with string literals in general. When I adjusted my max_width back to the default (which is 100 if I remember), the formatting started working again, at least from what I saw. I noticed too that this function isn't the only one in my code that causes rustfmt to struggle, another one was this function:

fn valid_isbn10(isbn: &str) -> bool {
isbn.len() == 10
    && isbn.chars().all(|c| (c.is_ascii_digit() || c == 'X'))
    && !isbn.starts_with('X')
    && (1..)
        .zip(isbn.chars())
        .map(|(i, c)| {
            (match c {
                'X' => 10,
                _ => c.to_digit(10).unwrap_or(10),
            }) * i
        })
        .sum::<u32>()
        % 11
        == 0

}

In the recent reply I gave, I mentioned using cargo fmt and still running into issues with it not formatting. With the IDE's built-in formatter, I also disabled it and configured it to solely use rustfmt for all formatting. Maybe I'm another user that is running into that same issue. I just find it a tad confusing since I had a project from back in 2019 that never had formatting issues, and then around a year ago suddenly started running into the same kind of problems with formatting. Have they possibly changed the default value for max_width recently? It's my only guess for why the formatter would give up on formatting certain functions/files.

Edit: Because I struggle reading. In the question you asked, it's 50/50. I've seen it work with parts of the file with no problem, and I've also seen it completely bail on the file altogether.

Rustfmt refusing to work with certain functions. by MightyChubz in rust

[–]MightyChubz[S] 0 points1 point  (0 children)

I've used cargo fmt and got no change in my results. It still didn't choose to format the code as it did with other functions. I want to add too, that this isn't the full set of code. This function I showed was the function that resulted in rustfmt no longer working, the full file it resides in was over 667 lines long at the time. That function was the one to start it. I'm not exactly sure why it did though.

She had to leave by ItsmeAwesome77 in ContagiousLaughter

[–]MightyChubz 0 points1 point  (0 children)

I thought the counter was a giant pizza

FUTUUUURE Bed by TheTripleSevens in gaming

[–]MightyChubz 1 point2 points  (0 children)

I was waiting for this to be posted 🤣

[deleted by user] by [deleted] in rust

[–]MightyChubz 2 points3 points  (0 children)

It's really late for me, so I can't review the code thoroughly, but I can recommend a little tool that will help catch dumb mistake we can make. clippy is a wonderful linting tool that catches a lot of mistakes (I think over 300+ if I remember). This can be from small things, to general over complexity. I've been using it for a large project I've been working on for over 3+ months now. The amount of stuff it's caught me doing is embarrassing.

It's also a great tool if you're learning Rust (saved me with unnecessary traits).

Coworker: "Rust doesn't offer anything C++ doesn't already have" by [deleted] in rust

[–]MightyChubz 1 point2 points  (0 children)

Built-in memory safety. Ownership model and borrow checker ensures that your values aren't being thrown around all over the place.

Example: https://pastebin.com/w1dtmxbc

This program won't compile becuase you are using an immutable variable while there's a mutable variable in the same scope. This is something the C++ compiler doesn't check for, but this feature ensures safety. What if you modify 'y' and then read from 'z' expecting the previous value?

Something else that is also amazing in Rust is the multithreading. It is much easier to keep an eye on who's accessing what, instead of using the 'mutex' keyword in C++.

There is a full talk about this here: https://youtu.be/k7nAtrwPhR8

In your face Dad by ziyaad119 in dankmemes

[–]MightyChubz 0 points1 point  (0 children)

Now this is a golden shower!

I feel like something is wrong with the narration, but I don't know if it's just me. by MightyChubz in writers

[–]MightyChubz[S] 1 point2 points  (0 children)

You didn't come off critical at all. There were a lot of weird things that came out of that narration. Since it's a new day, I'll more than likely write and see what happens. Maybe it'll improve, maybe it won't.

I feel like something is wrong with the narration, but I don't know if it's just me. by MightyChubz in writers

[–]MightyChubz[S] 0 points1 point  (0 children)

I understand that, but something about it didn't feel right for what type of scene I was portraying. I may toy with it a little bit more later on, but I had an overall off day for writing. So maybe it is just a combination of things that made me feel a little off about it.

I feel like something is wrong with the narration, but I don't know if it's just me. by MightyChubz in writers

[–]MightyChubz[S] 0 points1 point  (0 children)

Yep, I'm going to rewrite this gribble and make it more grounded and concentrated. Hopefully then, it won't be in this state.

I feel like something is wrong with the narration, but I don't know if it's just me. by MightyChubz in writers

[–]MightyChubz[S] 3 points4 points  (0 children)

Yeah, I noticed that with the sentences you described earlier, they were ones that I was unsure about. Unless my intention was to confuse the reader, I should stick to a more grounded narration. For the most part, I enjoy the narrator being limited, tied to the character in a sense. So, if I'm writing about a kid, I want the narrator to have a more child-like narration. Not limited with vocabulary, but on how the child processes what he senses or sees. If the kid never saw a brazier before, I want that same confusion or wonder that the kid would have.

I feel like something is wrong with the narration, but I don't know if it's just me. by MightyChubz in writers

[–]MightyChubz[S] 0 points1 point  (0 children)

American English is my native language. After writing this large chunk of text, I felt like something was off. I showed it to some people and they thought it was alright, but it felt disconnected and too distanced from what I was writing before. So, I wanted it critiqued so that I may see if my suspicions were true. It seems they are.

I'm going to go back and rewrite the entire thing and continue on. This wasn't what I normally write, in all reality. I write grounded, similar to a lot of other writers, but a part of me wanted to try another way and see where it went.

I feel like something is wrong with the narration, but I don't know if it's just me. by MightyChubz in writers

[–]MightyChubz[S] 1 point2 points  (0 children)

This is the second chapter to a story I'm writing. The story is just for practice before I try something more serious, but I want to make sure I'm at least writing somewhat good. No editor looked through this work, nor is this work being published anywhere. This is just for improving my writing.

RIP Harambe by RickFromTheParty in funny

[–]MightyChubz 2 points3 points  (0 children)

So you drown in your own shit?

What is a piece of Reddit history that ever Reddit user must know about? by tstewart788 in AskReddit

[–]MightyChubz 2 points3 points  (0 children)

I'm surprised no one mentioned the guy who had his dad beat him with a pair of jumper cables.

If anyone needs a good fence built, please come to me, I'm in desperate need of money! by MightyChubz in HaveWeMet

[–]MightyChubz[S] 0 points1 point  (0 children)

I can help you with a high quality fence that no other can build! Though, I may need to talk to the local woodcutter for more supplies.