>having to dereference an iterator for the modulus operator. >having to specify an obvious sum type

>having to dereference an iterator for the modulus operator
>having to specify an obvious sum type
This is what too much HRT does to a man

It's All Fucked Shirt $22.14

Shopping Cart Returner Shirt $21.68

It's All Fucked Shirt $22.14

  1. 4 weeks ago
    Anonymous

    pic related?

    • 4 weeks ago
      Anonymous

      Very related, I've wasted 300 seconds on this post, it better make rusttroons seethe

      • 4 weeks ago
        Anonymous

        Seems like the only one seething here is you.

      • 4 weeks ago
        Anonymous

        I don't the dereference in the code

  2. 4 weeks ago
    Anonymous

    > |x|*x
    What did OP mean by this

    • 4 weeks ago
      Anonymous

      I know you're deliberately misunderstanding for comedic effect, but if it meant absolute value that would be a way of squaring X while retaining the sign.

      • 4 weeks ago
        Anonymous

        That's not how you do it, lil bro...
        BTW, what font is that? Iosevka?

  3. 4 weeks ago
    Anonymous

    >filter
    >map
    >sum

    This isn't even programming. It's a query language.

    • 4 weeks ago
      Anonymous

      New to functional programming buddy?

      • 4 weeks ago
        Anonymous

        Yes never tried it

      • 4 weeks ago
        Anonymous

        it's not even explicitly functional anymore. many OO languages have them now. hell if you're still using for loops for 99% enumerating over something in 2024 i'm lmaoing at your life

        • 4 weeks ago
          Anonymous

          map and filter are functional, gay
          regardless if it's adopted by pOOP or not
          it's like saying black kid adopted by white parents makes the black kid white

          • 4 weeks ago
            Anonymous

            >map and filter are functional, gay
            no shit moron i mean the equivalent functions being available in non-functional languages. learn to read

      • 4 weeks ago
        Anonymous

        Yes and like all programming paradigms that aren't procedural, it's suckful.

  4. 4 weeks ago
    Anonymous

    iter gives you references. failing to see the problem here. sum type inference is garbage though, can also use a fold instead of map+sum

    • 4 weeks ago
      Anonymous

      The problem is that it's inconsistent as frick. map() didn't require any dereferencing for multiplication. If I swap .map and .filter I don't even need to dereference anything.

      • 4 weeks ago
        Anonymous

        it's not inconsistent. the closure passed to filter is a reference, you're returning a value from the map

        • 4 weeks ago
          Anonymous

          Oh good point actually

        • 4 weeks ago
          Anonymous

          I'm also passing a closure reference to map and I'm also returning a value from filter (an iterator), it doesn't seem consistent to me

        • 4 weeks ago
          Anonymous

          It's inconsistent because it has to be.
          map consumes an item and returns a different item. Therefore, map takes Item -> B.
          filter, on the other hand, checks if the item satisfies a predicate. It can't consume the item, because if it did, it wouldn't have an item left to yield. Therefore, filter takes &Item -> bool.
          filter_map combines map and filter, but it consumes the item the same way map does, taking Item -> Option<B>.
          let sum = [1, 2, 3, 4, 5, 6]
          .iter()
          .filter_map(|x| (x % 2 == 0).then(|| x * x))
          .sum::<u64>();
          That said, not implementing math operators on &&{integer} (and &&{float}) is a massive oversight for such an overengineered language.

          • 4 weeks ago
            Anonymous

            meant for

            The problem is that it's inconsistent as frick. map() didn't require any dereferencing for multiplication. If I swap .map and .filter I don't even need to dereference anything.

          • 4 weeks ago
            Anonymous

            >That said, not implementing math operators on &&{integer} (and &&{float}) is a massive oversight for such an overengineered language.
            Honestly, my biggest gripe with the language is this sort of thing. That and procedural macros. I would much rather just have compile-time rust code, similar to how zig does it.
            Also just macro syntax in general is total ass. I never remember how to structure it and always resort to looking it up.

      • 4 weeks ago
        Anonymous

        That's because the compiler automatically deref'd it for you, it's why
        let a = 5;
        let b = &a;
        let c = b + 5; // compiles
        let d = &b;
        //let e = d + 5; // doesn't compile
        let e = *d + 5; // but this compiles

        That's why you can write a function like this fn foo(itgr: &u32) -> u32 {
        itgr + 5
        }

        Instead of always having to deref it manually like this *itgr + 5
        >map() didn't require any dereferencing for multiplication
        You still do actually, you can check the closure signature yourself in VSCode, it still

        • 4 weeks ago
          Anonymous

          >That's because the compiler automatically deref'd it for you
          wrong, dumb moron
          see

          you are wrong, dumb moron.
          it works because there are multiple Mul implemetations
          impl Mul<&u64> for &u64
          impl Mul<&u64> for u64
          impl<'a> Mul<u64> for &'a u64
          impl Mul for u64

          so you can do 2 * &2 and &2 * 2, but not &&2 * 2.

          • 4 weeks ago
            Anonymous

            *Rust stdlib writer does it for you
            There I fixed it.

  5. 4 weeks ago
    Anonymous

    BURN THE HERUSTIC!
    KILL THE TROON!
    PURGE THE CRAB!

  6. 4 weeks ago
    Anonymous

    FOR THE EMPEROR!

    • 4 weeks ago
      Anonymous

      THEY KEEP THEIR VALUES IN RUSTY METAL BOXES!

  7. 4 weeks ago
    Anonymous

    in haskell this is just
    sum . map ((>>= id) (*)) . filter ((== 0) . flip rem 2) $ [1..6]

    • 4 weeks ago
      Anonymous

      Bruh
      sum . map (^2) . filter even $ [1..6]

      • 4 weeks ago
        Anonymous

        [1 .. 6]
        & filter even
        & map (^2)
        & sum

        • 4 weeks ago
          Anonymous

          Language?

          • 4 weeks ago
            Anonymous

            haskell
            & is just $ with the order or arguments and associativity flipped

    • 4 weeks ago
      Anonymous

      Bruh
      sum . map (^2) . filter even $ [1..6]

      Here is another cool one
      sum [x*x | x <- [1..6], even x]
      And in python
      sum(x*x for x in range(1, 7) if x % 2 == 0)

      • 4 weeks ago
        Anonymous

        python master race

  8. 4 weeks ago
    Anonymous

    What the frick is the .sum::<u64>?
    Is Rust too moronic to infer this?

    • 4 weeks ago
      Anonymous

      What type it should've been using by default, given you never specified it?

      • 4 weeks ago
        Anonymous

        The type of v[0].

        • 4 weeks ago
          Anonymous

          What is the type of v[0]?

          • 4 weeks ago
            Anonymous

            An integer, it's explicitly stated in the Rust documentation

          • 4 weeks ago
            Anonymous

            >there's only one type of integer
            hello moron

          • 4 weeks ago
            Anonymous

            [...]
            [...]
            [...]
            A clear example of what Javascript and/or Python do to a brain.

            Read RFC 212 before speaking again.

          • 4 weeks ago
            Anonymous

            https://www.rfc-archive.org/getrfc?rfc=212&tag=NWG-meeting-on-network-usage#gsc.tab=0
            How does this apply

          • 4 weeks ago
            Anonymous

            Rustards host their RFCs on ~~*Github*~~.
            Lol!

          • 4 weeks ago
            Anonymous

            oh, nevermind, it's a schizo moron c troony thread.
            cope and sneed trannies.
            Rust won.

      • 4 weeks ago
        Anonymous

        v - a vector of integers
        filter() - an iterator over integers
        map() - an iterator over integers
        gee I wonder what sum() should return

        • 4 weeks ago
          Anonymous

          iter is an iterator over references of integers

        • 4 weeks ago
          Anonymous

          What kind of integers? Signed or unsigned? 32 bits or 64 bits?

        • 4 weeks ago
          Anonymous

          The type of v[0].

          An integer, it's explicitly stated in the Rust documentation

          elements of a list could be any type

          A clear example of what Javascript and/or Python do to a brain.

      • 4 weeks ago
        Anonymous

        Whichever type is inferred if you do println!("{}", 0);

      • 4 weeks ago
        Anonymous

        elements of a list could be any type

    • 4 weeks ago
      Anonymous

      because of the way the Sum trait is defined. this means it can also return results and options. so it can't infer the type
      fn sum<S>(self) -> S
      where
      Self: Sized,
      S: Sum<Self::Item>,
      https://stackoverflow.com/questions/41017140/why-cant-rust-infer-the-resulting-type-of-iteratorsum

      • 4 weeks ago
        Anonymous

        That looks like shit design.

        • 4 weeks ago
          Anonymous

          you'd have similar problems in C++, dipshit.
          maybe learn HM

          • 4 weeks ago
            Anonymous

            Is that supposed to mean anything? C++ is the worst designed language ever.

          • 4 weeks ago
            Anonymous

            So it's shit design in 2 languages.

          • 4 weeks ago
            Anonymous

            no, in c++ you have operator overloading and default types that could avoid this case.

          • 4 weeks ago
            Anonymous

            function overloading, frick me

        • 4 weeks ago
          Anonymous

          why?

  9. 4 weeks ago
    Anonymous

    >dereference an iterator

  10. 4 weeks ago
    Anonymous

    >I'm moronic
    ok.
    maybe read the type signatures next time moron.

  11. 4 weeks ago
    Anonymous

    given you don't do anything with v after assigning s, you can literally just consume the container and not have to deal with references, moron.

    [1,2,3,4,5,6].into_iter().filter(|x| x % 2 == 0).map(|x| x*x).sum::<u64>()

    so hard.

    • 4 weeks ago
      Anonymous

      Rust was supposed to automagically dereference variables, guess it can't do that huh

      • 4 weeks ago
        Anonymous

        are you moronic? serious question, because you sound fricking moronic. stop touching things you don't understand.

      • 4 weeks ago
        Anonymous

        Only when using the dot operator. Frankly, I wish it used -> like C, but it's not a big deal either.

        • 4 weeks ago
          Anonymous

          no, only if the types match. that's why the x*x works in his code. &u64 and u64 aren't the same which is why he needs explicit deref or take the positional param by ref |&x| or do

          given you don't do anything with v after assigning s, you can literally just consume the container and not have to deal with references, moron.

          [1,2,3,4,5,6].into_iter().filter(|x| x % 2 == 0).map(|x| x*x).sum::<u64>()

          so hard.

          and into_iter which has a different type signature.

          • 4 weeks ago
            Anonymous

            you are wrong, dumb moron.
            it works because there are multiple Mul implemetations
            impl Mul<&u64> for &u64
            impl Mul<&u64> for u64
            impl<'a> Mul<u64> for &'a u64
            impl Mul for u64

            so you can do 2 * &2 and &2 * 2, but not &&2 * 2.

    • 4 weeks ago
      Anonymous

      i would just do this and avoid sum altogether tbh
      v.into_iter().filter(|&x| x % 2 == 0).fold(0, |sum, x| sum + (x * x))

      • 4 weeks ago
        Anonymous

        That's longer than specifying the type.

        Also what do when the numbers added are longer than i32?

        • 4 weeks ago
          Anonymous

          it's whatever the values are in the array, they became u64 when using the turbofish for sum.

        • 4 weeks ago
          Anonymous

          >Also what do when the numbers added are longer than i32?
          Then it'll crash in debug mode and do whatever in release mode.
          >rust "safety"

          • 4 weeks ago
            Anonymous

            >do whatever in release mode
            nope, that's C/C++. safe Rust is free from UB.
            https://doc.rust-lang.org/stable/reference/expressions/operator-expr.html#overflow

          • 4 weeks ago
            Anonymous

            >Integer operators will panic when they overflow when compiled in debug mode.
            It literally says what I just said. It doesn't define what happens in release mode, thus it's undefined behavior.
            >The exception for literal expressions behind unary - means that forms such as -128_i8 or let j: i8 = -(128) never cause a panic and have the expected value of -128.
            Also what the frick, did they put no thought into this shit?

          • 4 weeks ago
            Anonymous

            >It literally says what I just said
            wrong
            >It doesn't define what happens in release mode
            wrong
            https://doc.rust-lang.org/stable/reference/types/numeric.html#integer-types
            >Also what the frick, did they put no thought into this shit?
            You dumb moron. -128 is a valid value for an 8-bit signed integer.

          • 4 weeks ago
            Anonymous

            >wrong
            Where exactly does it say that it wraps?
            Also
            > Note: Many pieces of Rust code may assume that pointers, usize, and isize are either 32-bit or 64-bit. As a consequence, 16-bit pointer support is limited and may require explicit care and acknowledgment from a library to support.
            It's C all over again..

          • 4 weeks ago
            Anonymous

            >Where exactly does it say that it wraps?
            https://doc.rust-lang.org/stable/reference/behavior-not-considered-unsafe.html#integer-overflow
            >16-bit pointer support is limited
            nobody cares, even 32-bit is deprecated. 16-bit is giga deprecated.
            Also, I don't think LLVM even has support for 16-bit pointers on x86.

          • 4 weeks ago
            Anonymous

            >https://doc.rust-lang.org/stable/reference/behavior-not-considered-unsafe.html#integer-overflow
            OK so Rust integer safety is on the level of modern C.
            >even 32-bit is deprecated
            32 bit is still very important and the default in embedded scenarios. 16 bit still sees use there.

          • 4 weeks ago
            Anonymous

            >OK so Rust integer safety is on the level of modern C.
            wrong, signed integer overflow is UB in C.

          • 4 weeks ago
            Anonymous

            Right. C23 requires 2-complement's representation for signed integers, but didn't yet specify that operations on it should wraparound instead of being UB. Only C++ made that latter change. I hope the C standard committee (that's without doubt composed of idiots) can get itself to follow that change even if it makes some C programs slower by 0.1%.
            but you know, just because you became the kid who eats mud instead of dog poop, you're not the clever kid.

          • 4 weeks ago
            Anonymous

            >Other kinds of builds may result in panics or silently wrapped values on overflow, at the implementation's discretion.
            >at the implementation's discretion
            this is literally UB dude

          • 4 weeks ago
            Anonymous

            it wraps in release for signed and unsigned ints

  12. 4 weeks ago
    Anonymous

    What a horrible language. The only use case I can see is for certain libraries (e.g. SSL) that need to be both secure and fast, at the cost of developer experience. Even then, Ada would probably be better.

    • 4 weeks ago
      Anonymous

      >Even then, Ada would probably be better.
      thanks for exposing yourself as a larping nocoder

      • 4 weeks ago
        Anonymous

        I'm certainly not a nocoder, but I do admit I've never used Ada despite essentially advocating for it.
        My understanding is that Ada is widely used in safety-critical systems (ATC, fly-by-wire, medical, etc). That would seem to make it a good choice for widely-used security-critical libraries, too. Am I wrong about that?

        >The only use case I can see is for certain libraries (e.g. SSL) that need to be both secure and fast
        TLS can't be made secure in any high level language that's codegen'd by GCC or LLVM.

        Are you referring to timing/other sidechannel attacks? If not, please explain.

        • 4 weeks ago
          Anonymous

          There are some Ada dialects that did the right thing and that Rust is too midwit-ty to do: they added extensions for formal verification. This is how you get true safety, not
          >we force a rigid ownership model and refcounting everywhere
          >integer overflows cause an exception or "something else" depending on how you built it

        • 4 weeks ago
          Anonymous

          >Am I wrong about that?
          yes, it's slow and not pleasant to use at all. the design is stuck very far back in time, it's not good as a general purpose language and still lacks features rust has. also don't get confused with spark which is more rigorous but also lacking in some features compared to rust

        • 4 weeks ago
          Anonymous

          >Ada despite essentially advocating for it.
          Every Ada advocate, lol. Only fished out of the garbage bin for Rust discussions.

          • 4 weeks ago
            Anonymous

            >garbage bin
            more like nobody has access to a compiler worth anything because they're all priced in the five figures range, so the only people who are familiar with it are government contractors who don't talk about their work
            >g-gnu plus a-ada
            it's crap

          • 4 weeks ago
            Anonymous

            >thinking compiler == language
            >gnat is bad because... it just is okay?
            Holy midwit

          • 4 weeks ago
            Anonymous

            How do you propose people use a language without a decent way to turn it into executable code? Following from that, how do you propose people talk about a language when they can't apply it? Why do you think there would be in-depth and spurious discussion of a tool with no practical means to access the tool?

            Yes. The GNU Ada compiler is terrible. It's slow to compile, produces sub-par machine code, and is extremely buggy. GNATProve is a bad joke.

            You seem extremely upset about the fact that people bring up Ada alongside Rust. I'm not sure why, when Rust has set out to accomplish the same thing Ada has (to produce a safe systems language viable for real-time applications), and these are the only two languages to have done so outside of academic theory. I hope you realize this will never change. It's a natural adjacency that will never go away, and if you were actually interested in the concept of safe systems programming, you'd embrace and be interested in the only other extant production language that fits within this niche. Given your immense hostility, I can only assume you *aren't* actually interested in the concepts here though, and you only care about Rust for political reasons. Quite frankly, we don't need people like you in our community. I'm beginning to tire of baby ducks such as yourself misrepresenting our language and taking it upon yourself to act as "ambassadors". You are a disgusting, self-sabotaging autist and you do nothing but spread poison. You should not be allowed anywhere near a computer, let alone the internet. Cease your posting.

          • 4 weeks ago
            Anonymous

            tl;dr (not a request, just telling you)

          • 4 weeks ago
            Anonymous

            >How do you propose people use a language without a decent way to turn it into executable code?
            GNAT allows you to learn Ada pretty well. That's all that matters. You don't even want to learn Ada you nocoder.
            >text text text text
            not reading that shit homie

    • 4 weeks ago
      Anonymous

      >The only use case I can see is for certain libraries (e.g. SSL) that need to be both secure and fast
      TLS can't be made secure in any high level language that's codegen'd by GCC or LLVM.

    • 4 weeks ago
      Anonymous

      Do people really think memory safety is just about security? The main use case for rust's memory safety is making software reliable and reducing time spent debugging which applies to all software, not just security-sensitive stuff. Reducing debug time makes the developer experience far better than C or C++, which is why rust reliably wins 'most loved language' polls.

      • 4 weeks ago
        Anonymous

        >Do people really think memory safety is just about security?
        morons do, which is everyone who shits on rust for no reason and thinks we should only be using c/c++. unfortunately a large number of people who are dumb enough to think they never write bugs

  13. 4 weeks ago
    Anonymous

    >println!
    Ugly ass syntax

  14. 4 weeks ago
    Anonymous

    Why does filter require derefencing when it's placed first but map doesn't? That's just moronic

  15. 4 weeks ago
    Anonymous

    Hi, I'm OP. Thank you for your continued support in this tech support thread. You've answered all of my questions;). Cya frickers!

  16. 4 weeks ago
    Anonymous

    map takes a reference of course you have to dereference it and sum could either return u32,u64,i32 etc. if you specified the type for s instead that wouldn't be needed.

  17. 4 weeks ago
    Anonymous

    >obvious sum type
    How is that obvious? The answer could've fit in a u8. Since all numbers are known at compile time, without specifying a type I would have expected the optimizer to use the smallest one possible.

  18. 4 weeks ago
    Anonymous

    >anti-rust shills never actually know anything about the language
    pottery

  19. 4 weeks ago
    Anonymous

    >lets invent some trash semantics with auto defer, so glow Black folk can write their publish code once without thinking on what they are doing
    lmao

    • 4 weeks ago
      Anonymous

      What kind of moron thought that a reference should act like a pointer and not like an alias? This whole thing is a literal non-issue in C++

      dumb morons

  20. 4 weeks ago
    Anonymous

    What kind of moron thought that a reference should act like a pointer and not like an alias? This whole thing is a literal non-issue in C++

    • 4 weeks ago
      Anonymous

      ?t=165

    • 4 weeks ago
      Anonymous

      [...]
      dumb morons

      In C++ references don't get stacked:
      int x = 10;
      int& a = x;
      int& b = a;
      That is, b is of type int& and not int&&. Since int& is just an alias, every expression treats it just like the original value (int). You don't have to overload operators separately for int and int&. Now tell me how this is worse than Rust's way of pointers pretending to be references?

      • 4 weeks ago
        Anonymous

        dumb moron

      • 4 weeks ago
        Anonymous

        let a = 10;
        let b: &i32 = &a;
        let c: &i32 = &b;

        now what, dumb cnile?

        • 4 weeks ago
          Anonymous

          Now you should have the same situation as here

          That's because the compiler automatically deref'd it for you, it's why
          let a = 5;
          let b = &a;
          let c = b + 5; // compiles
          let d = &b;
          //let e = d + 5; // doesn't compile
          let e = *d + 5; // but this compiles

          That's why you can write a function like this fn foo(itgr: &u32) -> u32 {
          itgr + 5
          }

          Instead of always having to deref it manually like this *itgr + 5
          >map() didn't require any dereferencing for multiplication
          You still do actually, you can check the closure signature yourself in VSCode, it still

          since your references fricking stack.

          • 4 weeks ago
            Anonymous

            try reading, dumb moron. b and c are both &i32.

          • 4 weeks ago
            Anonymous

            Because you annotated them, but the language allows you to stack references and does that by default.

          • 4 weeks ago
            Anonymous

            so? If the programmer wants a pointer to a pointer then he should get one.

          • 4 weeks ago
            Anonymous

            That's what I'm talking about, your references are fricking pointers.

          • 4 weeks ago
            Anonymous

            yes, and?
            https://doc.rust-lang.org/stable/reference/types/pointer.html#references--and-mut

          • 4 weeks ago
            Anonymous

            Then call it a managed pointer and not a reference

          • 4 weeks ago
            Anonymous

            dumb moron

          • 4 weeks ago
            Anonymous

            insufferable troony

          • 4 weeks ago
            Anonymous

            Rust sisters, is this true? Are Rust references actually pointers? Isn't that slower than in C++?

          • 4 weeks ago
            Anonymous

            dumb moron, see

            yes, and?
            https://doc.rust-lang.org/stable/reference/types/pointer.html#references--and-mut

    • 4 weeks ago
      Anonymous

      >C++
      >Non issue

      > std::move, &&T
      > "a" + string("b") = &&T ? T?

      • 4 weeks ago
        Anonymous
  21. 4 weeks ago
    Anonymous

    x!

  22. 4 weeks ago
    Anonymous

    Rust sisters... What the frick is this..?

    • 4 weeks ago
      Anonymous

      The most Black personlicious way you could have written that code, sir

      • 4 weeks ago
        Anonymous

        *a = *a * *a

        is even more Black personlicious

        • 4 weeks ago
          Anonymous

          >mutable passing a word-sized copy type by fricking pointer and returning the result
          Good morning, sir!

          • 4 weeks ago
            Anonymous

            >and returning the result
            typo. mean to say "not just consuming and etc

          • 4 weeks ago
            Anonymous

            This function returns (). It squares a variable in place, how else would you implement it mr smart?

          • 4 weeks ago
            Anonymous

            Yes, read

            >and returning the result
            typo. mean to say "not just consuming and etc

            . It's what you _should_ have done

          • 4 weeks ago
            Anonymous

            >just don't do that in place, Rust doesn't support that!!!

          • 4 weeks ago
            Anonymous

            There is zero (0) reason to do this in place

          • 4 weeks ago
            Anonymous

            Doing things in place shifts the assignment from the end user to the library you dumb frick.

          • 4 weeks ago
            Anonymous

            Imagine being so panty-blasted about writing:
            let b = sqr(a);

            Are cniles this allergic to functional-style programming?

  23. 4 weeks ago
    Anonymous

    God I hate this shit ass language. Just give me c++.

  24. 4 weeks ago
    baritone

    in x86 assembly its just:
    section .text
    extern printf
    global main
    main:
    push ebp
    mov ebp, esp

    xor edx, edx ;result
    xor ebx, ebx ;i
    .loop:
    mov al, byte [arr + ebx]
    inc ebx ;i++
    bt eax, 0 ;bit test to preserve value
    jnc .loop ;ignore if its an even value

    add edx, eax ;accumulate sum
    cmp ebx, 5
    jl .loop

    push edx
    push str_format_num
    call printf

    xor eax, eax
    mov esp, ebp
    leave
    ret
    section .data
    arr: db 1, 2, 3, 4, 5, 6

    str_format_num: db 'sum of odd numbers: %d ', 13, 10, 0

    • 4 weeks ago
      Anonymous

      >using a loop
      >not using SIMD instructions
      ngmi

      • 4 weeks ago
        baritone

        >i need the macro to do it for me

        • 4 weeks ago
          Anonymous

          >writting slower code that more complicated makes you better

        • 4 weeks ago
          Anonymous

          (you) clearly need that macro since you didn't use any AVX registers in your implementation

  25. 4 weeks ago
    Anonymous

    u64 is not at all obvious. The de reference can be done in the parameter pattern like |&n| n % 2]/code], yes it's awkward.

Your email address will not be published. Required fields are marked *