cargo new nicfitzgerald · @nicfitzgerald
22 followers · 97 posts · Server hachyderm.io

Going over ownership in the book again and it makes so much more sense this time around.

#learnrust

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
1044 followers · 1327 posts · Server infosec.exchange
Astra Kernel :verified: · @AstraKernel
1020 followers · 1274 posts · Server infosec.exchange

πŸ¦€

What is the output of this?

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

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

#rustquiz #RustChallenge #rustlang #rust #rusttips #learnrust

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
999 followers · 1226 posts · Server infosec.exchange

✨ Rust Challenge explained

Ans:
2. A gives output and B gives error

In `A` code:
πŸ‘‰ x will be assigned to i8 type since we are using i8 to compare in assert_eq.

πŸ‘‰ x.pow(6) will be 2 power 6 which is 64, it will work perfectly

In `B` code:

πŸ‘‰ x will be assigned default to i32

πŸ‘‰ But in second line you will get ambiguity error 🀯

πŸ‘‰ And compiler will ask to specify the type for x explicitly

#rustlang #learnrust #rusttips #rust

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
997 followers · 1213 posts · Server infosec.exchange

πŸ¦€ 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)

#RustChallenge #rustlang #rust #learnrust

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
997 followers · 1213 posts · Server infosec.exchange

✨ Yes, the answer is C

It prints:
-10
+100

🎯 What is the use of `+` in format string?

πŸ‘‰ By default, number sign is not printed for positive numbers

πŸ‘‰ We use `+` to print sign also

print!("{:+} {:+}", 1, -2);

It will print
+1 -2

#rustlang #rusttips #rust #learnrust

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
995 followers · 1210 posts · Server infosec.exchange

πŸ¦€ Format String tricks - Minimum width

πŸ‘‰ You can set minimum width for the characters that gets printed

Eg:
{var_name:min_width}

πŸ‘‰ Helps to ensure that fields in the output are of a uniform width

play.rust-lang.org/?version=st

#rustlang #rusttips #rust #learnrust

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
991 followers · 1206 posts · Server infosec.exchange

✨ Using variable inside Format String

πŸ‘‰ It appears many people are not aware of this syntax that was introduced in Rust 1.58(2022/01/13)

πŸ‘‰ You can also use format specifiers along with it

#rustlang #rusttips #rust #learnrust #programming

Last updated 2 years ago

Hot take: learning rust is easy, I learnt it in one day by sitting down and just coding for hours at a time. I know I prb learned way less than half the language but at least I'm to the point where I can write a semi complex program which implements structs, traits, functions and implementation blocks etc.

#rust #developer #learnrust #foss

Last updated 2 years ago

πŸ“’New in MEAPπŸ“’

Want to level up your programming skills and learn Rust?

Learn Rust in a Month of Lunches by @Mithridates, will teach you to build real software, understand messages from the compiler and Clippy, make informed decisions on types, work with external crates, and even write your own macros.

Transform yourself into a Rustacean in 22 short lessons: mng.bz/Q84w

Get 45% off with code mlmacleod till Feb 3.

#rustlang #learnrust #rustacean #rust

Last updated 2 years ago

Jan :rust: :ferris: · @janriemer
412 followers · 922 posts · Server floss.social

Are you a person who constantly questions the status quo?

Do you prefer over quantity?

Do you value technical excellence?

Do you want to empower others to become their best selfes?

Do you value an inclusive and friendly community?

Then join us 's on the exhilarating ride that is learning !

(and if you like crabs πŸ™‚ :ferris: 🎑 )

#learn #learnrust #learning #inspiration #rustlang #Rust #rustacean #quality #curious

Last updated 2 years ago

~ashwinvis · @ashwinvis
441 followers · 268 posts · Server mastodon.acc.sunet.se

I solved the second part of day 3 challenge in using a generic function - ridiculously hard to get the types right that it compiles, but I think I understand the gist of it.

codeberg.org/ashwinvis/advent-

#adventofcode #learnrust #rust

Last updated 2 years ago

Jan :rust: :ferris: · @janriemer
396 followers · 604 posts · Server floss.social

Wait, is this...a Ferris wheel!? :awesome:

🎑

Do you know what that means?

It means you should go along for the beautiful and exhilarating ride that learning is.

And Ferris, the crab, will always be on your side, so you have no reason to panic!. :ferris: πŸ™‚

RustLang

#emoji #ferriswheel #ferris #learnrust #Rust

Last updated 2 years ago

~ashwinvis · @ashwinvis
426 followers · 237 posts · Server mastodon.acc.sunet.se

I just completed "Calorie Counting" - Day 1 - Advent of Code 2022 adventofcode.com/2022/day/1

Yes, I know. It took a long time to do both parts. But hey, great opportunity to .

Criticisms welcome:
codeberg.org/ashwinvis/advent-

#AdventOfCode2022 #rust #learnrust #adventofcode

Last updated 2 years ago

~ashwinvis · @ashwinvis
427 followers · 230 posts · Server mastodon.acc.sunet.se

Once again, trying to pick up via solving puzzles. I understand most of the things now, but it is still taking time to implement the algorithm I have in mind.

One thing I don't get is why a few methods return a Some / None option and others return a Ok / Err objects. Why do we have two such constructs? Aren't they similar?

#AdventOfCode2022 #learnrust #adventofcode #rust

Last updated 2 years ago