home.social

#rustchallenge — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #rustchallenge, aggregated by home.social.

fetched live
  1. 🦀#RustChallenge

    This will throw a compilation error

    Fix this code in a short or better way

    (Btw, this might compile in the future and work. Because, It was said that shortcomings of rustc & will be fixed in future)
    #rustlang #rust

  2. #RustChallenge

    What will be result?

    A. Both X & Y will give error
    B. Y will give error & X will print "Kernel" and "Astra"
    C. X will print "Kernel" & Y will print "Kernel" and "Astra"
    D. both prints "Kernel" & "Astra"

    (it was shared in ThePrimeagen stream by one of viewers)

    #rustlang #rust

  3. 🦀 #RustChallenge

    Will it print Hello World?

    A. No, it will give compilation error

    B. Yes, it will print `Hello World`

    C. No, it will panic at runtime but prints 1

    This challenge was brought to you by @tuxmain

    #rustlang #rust #developer

  4. @AstraKernel I have a #RustChallenge for you.

    What will be the output of the following code:

    - A) nothing, it's not valid rust code 😞
    - B) nothing, it will crash runtime 💩
    - D) something nice 😻
    - E) undefined behavior 💀
    #rust #cpp #unsafe #gnu #crablang #imsorry #nice

  5. 🦀 #RustChallenge

    What will be the output in "Nightly"?

    A. Compilation error (already mentioned nightly so it might run, but will you trust me? 😜)

    B. prints "return"

    C. prints "!"

    D. prints nothing

    It's been a long time since I posted (found this in discord)

    #rustlang #rust

  6. 🦀 #RustChallenge:

    What is the output?

    A. Both X and Y prints "True" and "False"

    B.
    Only Y prints "True" and "False"
    X just prints "False"

    C. Gives compilation error

    D. Runtime error

    i know i know, sorry... :P

    #rustlang #rust

  7. 🦀#RustChallenge

    What is the output?

    A. Prints memory address 3 times

    B.
    "Rust"
    Memory Address
    Memory Address

    C.
    "R"
    "u"
    "st"

    D.
    "Rust"
    "Rust"
    "Rust"

    #rustlang #rust

  8. ✨ Rust challenge explained

    Ans: C. It never reaches the prints statement. It goes in an infinite loop 😲

    But, how? Let's break down

    👉 End value is 0xfffffff which is 268435455.0. it is not very important here. So let's remove it and simplify the code with a constant 20,000,000.0 end value

    👉 `f` value stops increasing(round upped) after value 16777216.0 when you add just 1.0 🤯

    👉 To know why,you have to understand how the f32 is stored. Float is not stored as simple as integer

    👉 f32 uses IEEE 754 format to store the value

    👉 Larger f32 number loses accuracy

    In a 32 bit float (any language not just rust):

    👉 1st bit is used for sign identification (positive or negative)
    👉 Following 8 bits used for exponent
    👉 Next 23 bits used for storing mantissa 🙃

    You can see more here, how it is calculated
    youtu.be/8afbTaA-gOQ

    (Continued 👇)

    #rustlang #RustChallenge #programmers #rust

  9. 🦀 an Interesting #RustChallenge given by @sombrastudios

    What will happen?

    A) prints "Hello World" instantly
    B) prints "Hello World" after 3 seconds
    C) never reaches the print statement
    D) Compilation error

    #rustlang #rust

  10. 🦀 #RustChallenge

    What will be the result?

    A. Runtime error
    B. Compile time error
    C. It won't give an error and does nothing

    Credits : @musicmatze

    #rustlang #rust

  11. #RustChallenge:

    What is the output?

    A. It will print Kernel

    B. It will give a compilation error (explain why)

    C. It will give a runtime error (explain why)

    #rustlang #rust

  12. 🦀 #RustQuiz

    What is the output of this?

    A. Error
    B. RustJsPython
    C. (Rust, Js, Python)
    D. Rust

    (Not hard/tricky or unique as #RustChallenge, just simple quizzes)

    #rustlang #rustquiz #rust #rusttips #LearnRust

  13. #RustChallenge

    🦀 Fix the following code

    🪲 Error: "cannot borrow `x` as mutable because it is also borrowed as immutable"

    Playground link:
    play.rust-lang.org/?version=st

    👉 You can answer either with fixed playground link or just explanation (No poll)

    #rustlang #rust #LearnRust

  14. 🦀 #RustChallenge

    What is the result?

    A.
    -10
    100

    B.
    10
    100

    C.
    -10
    +100

    D.
    +10
    +100

    #rustlang #rust

    Vote here 👇

  15. 🦀 #RustChallenge

    What is the result?

    A. Error
    B. Prints 2 4 6 8
    C. Prints 2
    D. Prints 2 6 8

    #rustlang #rust

    Vote here 👇

  16. ✨ Underscore expressions in Rust

    Underscore `_`, a reserved identifier - Anything passed to into it will be ignored(But careful, it is not dropped)

    👉 Underscore doesnt copy,move or borrow the value

    👉 In the following code, we create String instance 'x'.We pass it to the underscore which does nothing than ignoring whatever we give. It does not move the ownership.
    Ownership still remains with 'x' 😱

    let x = String::new("Kernel");
    let _ = x;

    👉 Then what is the use?

    👉 It will be useful in situation, when you are not interested in a certain value and ignore it.

    For example:
    fn main(){
    let x = (21, "Parker");
    let (age, _) = x; //Ignore the name, only want age from the tuple.
    println!("age: {}", age);
    }

    Resources:
    runrust.miraheze.org/wiki/Unde

    Underscore is not exactly "throw away" but rather it is exactly "don't bind to variable:
    news.ycombinator.com/item?id=2
    reddit.com/r/rust/comments/96z

    #rustlang #rust #rustaceans #RustChallenge

  17. 🦀 #RustChallenge

    What is the result?

    1. A and B both print "Kernel"
    2. A prints "Kernel" and B gives error
    3. B prints "Kernel" and A gives error
    4. A and B both gives error

    #rustlang #rust

    Vote your answer here 👇

  18. 🦀 One more #RustChallenge for today on the same concept

    A.
    Starting race
    Ending race
    140
    280

    B. Error (explain why)

    C.
    Starting race
    140
    280
    Ending race

    D.
    Starting race
    Ending race
    280
    140

    #rustlang #rust

    Vote your answer here 👇

  19. #RustChallenge

    What is the result?
    A.
    Hello
    Drop it - Samson
    Drop it - Ross
    Bye, World

    B.
    Hello
    Drop it - Ross
    Drop it - Samson
    Bye, World

    C. Error (explain why)

    D.
    Hello
    Bye, World
    Drop it - Samson
    Drop it - Ross

    #rustlang #rust

    You can also vote 👇

  20. 🦀 #RustChallenge

    What is the result?

    1. A and B will print 5 5
    2. A will give error and B prints 5 5
    3. B will give error and A prints 5 5
    4. Both will give error

    #rust #rustlang

    (Boost this post if you like this challenge)

    You can reply or Vote your answer here in the poll
    👇

  21. 🦀 #RustChallenge

    What will be the result?

    1. Both A and B will print `true`
    2. B will give an error and A will print `true`
    3. A will give an error and B will print. `true`
    4. A and B both will throw error

    * Idea source will be shared later

    #rust #rustlang #rustaceans
    You can also vote your answer 👇

  22. 🦀 #RustChallenge

    Two sets of codes. What will be the result?

    1. A and B will print "1 2 3" two times

    2. A will throw an error (explain)

    3. B will throw an error (explain)

    4. A and B will throw an error (explain)

    #rustlang #rust #rustaceans

    You can also vote your answer here 👇

  23. 🦀 #RustChallenge

    What is the output?

    A. Hello world!
    B. Helloworld!
    C. Moo
    D. "no method named `contains` found for enum `Cow<'_, str>`"

    #rustlang #rustaceans #rust #rustacean