I thought I would teach myself Rust, apparently can't get Python out of me

Text description (for those with screenreaders):

A portion of a prime number checker written in the Rust programming language, where the first few lines are written correctly including the first if statement in the program. However, the following if statements are written using Python syntax instead of Rust, as the author slipped back into his native tongue.

Ephera,

Once you’re happy with your own implementation, you may be interested in this rather rustic implementation I created a little while ago: codeberg.org/trem/erastothenes-iter/src/…/lib.rs

It’s actually just an iterator for primes, but building a function around it which checks whether a given number is prime shouldn’t be difficult.

It’s probably quite overwhelming, but you don’t have to learn all these concepts all at once. I started out much like you and then learnt many of the nuances hidden in there over the course of multiple years. It’s fine, if it doesn’t look all idiomatic from the start. Just as a bit of a pre-taste where your journey might lead. 🙃

skullgiver, (edited )
@skullgiver@popplesburger.hilciferous.nl avatar

deleted_by_author

  • Loading...
  • JustARegularNerd,

    I was pleasantly surprised by how good the error messages are in Rust though on compile time. I agree that having an IDE flag them before I compile is much better though.

    agressivelyPassive,

    That’s why you use a proper IDE, that checks everything as you type.

    t3rmit3,

    Yeah, like Vim. Who uses nano to code?

    JustARegularNerd,

    Well, in my defense I just wanted to initially try out Rust and on this particular computer, I don’t have any IDE set up on it yet. However, definitely seems like an IDE is in order for me haha

    t3rmit3,

    I was just being facetious by suggesting another commandline editor. ;P

    JustARegularNerd,

    I thought so but as I’m not a huge vim user myself, I thought maybe vim had some error detection like VSCode that could be set up and that’s what you meant.

    In any case, VSCode will probably be the go for me

    robinm,

    vim can have IDE-like capabilities thanks to lsp and tree-sitter. That’s a real game changer and is quite easy to set-up with something like kickstart.nvim.

    t3rmit3,

    I actually use Vim to write all my code, but without IDE-ifying it, just syntax highlighting and some navigation tweaks (with Sublime3 for help with bulk edits). For most of my stuff an IDE is overkill.

    jarfil,

    That’s not a command line editor, this is a command line editor 😜

    en.m.wikipedia.org/wiki/Ed_(text_editor)

    hallettj,
    @hallettj@beehaw.org avatar

    I did not realize nano implemented syntax highlighting!

    JustARegularNerd,

    I’m not sure what does and doesn’t control it, but I’ve installed nano on some Linux distros and it has no syntax highlighting at all, then other distros (currently using LMDE) just have it by default.

    Fal,
    @Fal@yiffit.net avatar

    Seriously. I can’t imagine writing rust without an IDE, that’s absurd. Rustrover is amazing

    Cwilliams,

    What is Rustrover? Whatever it is, that’s an awesome name

    Fal,
    @Fal@yiffit.net avatar

    Jetbrain’s rust IDE

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programming@beehaw.org
  • ngwrru68w68
  • DreamBathrooms
  • modclub
  • GTA5RPClips
  • InstantRegret
  • magazineikmin
  • Youngstown
  • thenastyranch
  • rosin
  • slotface
  • mdbf
  • khanakhh
  • kavyap
  • anitta
  • tester
  • normalnudes
  • Leos
  • cisconetworking
  • osvaldo12
  • everett
  • Durango
  • tacticalgear
  • provamag3
  • megavids
  • ethstaker
  • cubers
  • JUstTest
  • lostlight
  • All magazines