• 5 Posts
  • 474 Comments
Joined 2 years ago
cake
Cake day: July 8th, 2023

help-circle



  • Tsoding has created a few rules for writing Rust to make Rust “fun” to program in, and gave them the name of Crust.

    Here is the rule set (it may change over time):

    1. Every function is unsafe.
    2. No references, only pointers.
    3. No cargo, build with rustc directly.
    4. No std, but libc is allowed.
    5. Only Edition 2021.
    6. All user structs and enums #[derive(Clone, Copy)].
    7. Everything is pub by default.

    If you ever want to try this out for some ungodly reason, there’s a GitHub repository with an example Main that shows how to use libc and other libraries (in the example, it’s raylib), and with a Makefile showing how to compile your projects (remember we aren’t using cargo).




  • Wait, now I need to know why.

    * some time later *

    I went to check why the hell this happened. It looks like the pair (“(,)”) is defined as an instance of Foldable, for some reason, which is the class used by functions like foldl() and foldr(). Meanwhile, triples and other tuples of higher order (such as triples, quadruples, …) are not instances of Foldable.

    The weirdest part is that, if you try to use a pair as a Foldable, you only get the second value, for some reason… Here is an example.

    ghci> foldl (\acc x -> x:acc) [] (1,2)
    
    [2]
    

    This makes it so that the returned length is 1.




  • I just had an idea! It’d be really cool if I made you a website that retrieved the last image you uploaded, read the comments sorted by upvotes, added the pixel, uploaded the image to your instance, and made a new post; and while doing so, it’d be cool if it showed you every step of the process so you could see if things were going fine. It’d be cool, but it would take at least a month for me to make…

    As with finding the coordinates and the color hex code in every comment, I believe to know a way to approach this problem that would work 97% of the time.