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
    link
    fedilink
    arrow-up
    4
    ·
    5 months ago

    Once you’re happy with your own implementation, you may be interested in this rather rustic implementation I created a little while ago: https://codeberg.org/trem/erastothenes-iter/src/branch/master/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. 🙃