Not sure if you were ever going to mention this, but you can actually print tuples, arrays and so forth. Instead of doing println!("{}", ('h', 'i', 1, 2, 3)), which would give you an error, you can use the debug print which has the following syntax: println!("{:?}", ('h', 'i', 1, 2, 3)) or println!("{:#?}", ('h', 'i', 1, 2, 3)), the latter one giving you a neatly formatted output. Overall a nice and informative video!
@TechWithTim2 жыл бұрын
thank you! always appreciate the extra tips and hopefully this will help some people out in the comments :)
@gurnkerk38262 жыл бұрын
@@TechWithTim also you can implement the fmt::Display trait, so you decide how {} will show the tuple ;) for {:?} impl fmt::Debug
@razdevra63612 ай бұрын
@@gurnkerk3826 i really wanna learn this extra material would you like to be a part of my project
@interclosure Жыл бұрын
You actually CAN convert some int types, like in the case at the end of the video, this will work: let x: u8 = 4; let y: i32 = x as i32; OR let y: i32 = x.into(); Hope it helps
@madman77765610 ай бұрын
I was actually just about to comment about how interesting it would’ve been if you couldn’t. Especially since coming from learning Java I’m used to the concept of putting a smaller box(u8) into a bigger box(i32) which should work. Thanks man!
@someaddictedidiot21869 ай бұрын
You are my savior!
@unstableisotopeiscool9 ай бұрын
it says this in the error message
@shirazbabar8892 Жыл бұрын
At 4:28, I would like to provide a clarification. The accurate formula for determining the range is -(2^(n - 1)) to (2^(n - 1)) - 1. As a result, the range for the signed 8-bit integer (i8) would be -128 to 127.
@ethanmcintosh-locke8924 Жыл бұрын
thank you, i was wondering why the rules were so loose when he was explaining it
@mbrav2 жыл бұрын
You really hit on very important details that I have not seen in tutorials when I first tried Rust 5 months ago. Thanks!
@earlchesterantonio15812 жыл бұрын
Wow this tutorial series is very useful since i'm looking for a low level language to learn
@nickheyer Жыл бұрын
Tim, I think you are confusing bool types in rust with other languages. A non-zero int does not mean true. In fact, if you attempted to declare 0 or 1 as a bool var as you did in your example, you'd get a compiler error: "expected 'bool' , found integer".
@bommanaakash5900 Жыл бұрын
yea
@grafsamuel2766 Жыл бұрын
confirmed
@ifeanyinneji77046 ай бұрын
Thanks
@oneilmw Жыл бұрын
Very important for arrays: the type usize was not discussed. It is "basically a u32 or u64"*** variables with this type are unsigned integers, but have a bit-length which can vary based on the system it is compiled on. More specifically, they are unsigned integers of bit-length equal to ( the bit-length of a pointer at compile time ). usize is important to discuss early because it is the expected data type for the index argument of an array. Example: fn main() { let array_name: [u32; 3] = [0, 1, 2]; let index: usize = 2; let output: u32 = array_name[index]; println!("{}", output); }
@mukund49262 жыл бұрын
hey Tim. can Rust replace C and C++ in the future? currently what kind of jobs use Rust?
@binds30632 жыл бұрын
Jobs in Rust now are pretty minimal atm afaik. But they are going up from what I have heard. I personally don’t think that many current projects in C and C++ will port over to Rust because that would kind of be unreasonable, but I do think Rust will probably be the way to go for systems programming in the future. I don’t really think that C or C++ can be fully replaced though. They are staples in the field of programming languages. Rust will definitely be a very big and widely used language in the future imo
@frroossst42672 жыл бұрын
C? not really, C++? many people tend to think so, like the creator of npm and deno, people wayyy smarter than me
@jma422 жыл бұрын
most likely because of memory safety and tooling, the only stuff keeping them intact in c++ is because of library support that rust lacks. C is not going away. however I'm quite positive that rust might be going to be higher level in future and might even have the abstraction similar to python, while also retaining low-level control.
@marcotroster82472 жыл бұрын
@Mukund I pretend that the application of Rust is mostly in low-level hardware drivers where correctness, pedantic precision and scientific programming matter. But you really need to have the personality to fit this kind of job and not get burned out. It's not always about job opportunities and money in software. The tasks arise from themselves if you wanna achieve certain goals. Languages are just tools, don't tunnel too much on learning them to perfection. Rather try to understand how a PC works. That's my best advice I can give 😉
@TeddieMovie Жыл бұрын
@@marcotroster8247 very nicely said!
@dmaster20ify6 ай бұрын
the range of signed integers is implementation defined for compiled languages.
@hamdysaadpersonal2 жыл бұрын
We need next how to convert between then easly , like string to i32 ,&str to String ; just something like that
@binds30632 жыл бұрын
&str to String would simply be calling to_string() on the &str. String to i32 would be through the parse method: let string_to_int = "10".to_string().parse().unwrap(); for example. Or with the turbo fish syntax to specify the type of F: let string_to_int = "10".to_string().parse::().unwrap();. parse will work for both &str and String.
@hamdysaadpersonal2 жыл бұрын
@@binds3063 nice , i tried to make a program that takes a string then match it with the area of shapes , for example the user input is square so it will run other function called square(); that takes two other inputs then return the area ; anyway i'm stuck at the match thing because of the data types conversion .
@alienews04 ай бұрын
11:41 mm no warning despite u never read that tup before modifying it... That's one implicit promise of the debugger broken there ^^
@jasongracae17802 жыл бұрын
Which font are you using?
@introspecticon2 жыл бұрын
Good video, but I don't understand why you left out strings. Coming from a Python background the difference between String objects and string literals in Rust was very unintuitive to me.
@TechWithTim2 жыл бұрын
It will be explained in a future lesson!
@HughvanZyl Жыл бұрын
I'd imagine "tuple" should actually be pronounced similarly to "to pull", according to English spelling rules. Because there is only a single "p", and the "u" is not the second last letter, the vowel makes a long sound, not short, and because there is a silent "e" at the end, the sound the vowel makes shifts, roughly from the sound it would make in a word like "up", to the sound it would make in a word like "mute".
@craftydoeseverything97189 ай бұрын
That is fair, however, the reason why it is usually pronounced with the "u" as in "up" is because the word "tuple" originates from words like "pentuple", "hextuple", "octuple", etc.
@eeronat7 ай бұрын
There are three variants to the pronunciation, not two. All are used. The arguments are just for popcorn.
@HughvanZyl7 ай бұрын
@@eeronat k? Well i hope you enjoyed mine
@eeronat7 ай бұрын
@@HughvanZyl sure did. You're a scholar.
@SlyPearTree2 жыл бұрын
This has nothing to do with Rust but I have to know: why does his start menu open every time he switch from his editor to an already opened console?
@letsgocamping882 жыл бұрын
Thin he's hitting Windows key to show the task bar.
@frozenn00b Жыл бұрын
He uses Windows key to expose the task bar so he can use the mouse to switch to the command prompt instead of using the ALT+TAB key combination. Personally find it annoying, ALT+TAB has been around for decades, longer than the Windows key.
@subee1282 жыл бұрын
Thaanks
@albatroshd79453 ай бұрын
8:23 as a German we spell tupel with a long u
@thewelder35385 ай бұрын
Just some feedback here. Firstly, if someone is unsure, they should probably use double over a float. So f64 if unsure rather than f32. You explanation of signed integer ranges is a little complex to someone who doesn't understand. -128 to -127 could look like it could simply store these two values. It actually might have been easier if you'd explained in-terms of the sign bit. If the top bit is set, it's considered to be negative and this way, it works for all sizes of integer, from i8 to i64 etc. Then when you discuss char, you don't actually say how many bits that char is. How would it deal with a unicode char? I'm not a Rust programmer, I've been a C++ dev for like 30+yrs at a well known software house but thought I'd check out your videos. They're good, but for someone who knows how to code, they'll have a lot of questions you don't answer. As an example, when you talk about bool, you say 0 is false and 1 is true... But is 2 true? In C++ anything other than zero is true.
@bradfin124 ай бұрын
I32 contains whole numbers but only half of the possible values are whole. u32 are all whole numbers.
@mortaldev49992 жыл бұрын
If i have a tupple with type (i32,bool,char) then does rhe sequence matter
@Royaleah2 жыл бұрын
;good videos;
@ryanbohling76994 ай бұрын
Is the reason i8 range is -128 to 127 instead of -255 to 255 because the minus sign is taking a bit?
@TechWithTim4 ай бұрын
Yep!
@ryanbohling76994 ай бұрын
Perfect. Thanks dude!
@DuyTran-ss4lu2 жыл бұрын
Cool
@init15082 жыл бұрын
So tuples are mutable while arrays are not, totally different from python
@zarith2 жыл бұрын
13:57
@miguelguthridge2 жыл бұрын
No, tuples are immutable by default, just like in Python (although unlike Python they can be made mutable). They are always fixed length though.
@init15082 жыл бұрын
@@zarith Oh thanks a lot
@init15082 жыл бұрын
@@miguelguthridge thanks!
@ohwow20742 жыл бұрын
Everything is immutable by default. So are the tuples
@xxorza Жыл бұрын
So I spend about 40 minutes on these videos, but then switched tab to my paid chatGPT and my learning got much faster. Thanks for your work, though.
@faatemehch9611 ай бұрын
👍🏻
@willsterjohnson Жыл бұрын
"too-pul" and "tuh-pl" are both correct pronunciations of tuple. Just like "om-ni-puh-tunt" and "om-nee-poh-tunt" are both correct pronunciations of omnipotent. What *is* an incorrect pronunciation though is "pro-nown-see-ay-shun", the correct way is "pro-nun-see-ay-shun"
@madhuvarun2790 Жыл бұрын
How are you getting autocomplete feature?
@kartikchauhan27782 жыл бұрын
What is the use and applications of rust ??
@nanulanu2 жыл бұрын
basically everything, for example Pop_OS! is rewriting their whole GNU/Linux based OS in rust, because it is a very fast language
@nanulanu2 жыл бұрын
@@user-se6in3lb9s I didn’t say it’s the fastest, I just said it’s very fast
@binds30632 жыл бұрын
Systems programming, backend web development, front end web development (with WASM), cross-platform app development, block chain/web 3 development, etc. it is a general purpose language
@jdf0262 жыл бұрын
smart contract writing for Solana
@frozenn00b Жыл бұрын
@@nanulanu No, Linux is not rewriting the entire OS to be Rust. Hell, the kernel is barely getting limited Rust *support* in 6.1. C/C++ isn't going anywhere for a long time. Pop_OS! is rewriting their window manager (GUI shell) in Rust, but that's not "whole GNU/Linux based OS".. that's an application.
@sepsmusic2 жыл бұрын
it's not a tupple it's a tuple
@johnnytoobad77852 жыл бұрын
Does Python have an interface for Rust or vice-versa ?
@ya4dang1 Жыл бұрын
Anyone find that popping menu distracting?
@grzegorzryznar510111 ай бұрын
Seems weird why elements from tuples is accessed by attribute and not by index
@gabiold6 ай бұрын
Probably because it is semantically closer to a struct with unnamed members than to an array of alike elements.
@lsatenstein Жыл бұрын
How do I pin your KZbin channel to my cellphone. I am just auditing your course. I am an 83 years young senior. I have been doing software engineering for the past 55 years. My favorite language is C.
@antilogism11 ай бұрын
I've 'been coding C for 37 years (with some VHDL, Octave/Matlab & Python projects for work and some OpenSCAD on the side). This is way different but I like it so far.
@kutoru Жыл бұрын
3:12 WYSI
@worldhack.12012 жыл бұрын
Where we can use rust except desktop applications?
@jankapko93382 жыл бұрын
Rust is a low level programming language so you could write anything from an operating system, a video game, a graphical desktop application to a dynamic website.
@iamworstgamer Жыл бұрын
which theme you are using in vscode
@ssisaiasАй бұрын
is it Sublime Text, not vscode
@liambarrack891410 ай бұрын
too-ple gang
@NouifrUIwefdf Жыл бұрын
He is wrong about booleans. Rust is very explicit, "bool" has to be "true" OR "false" and nothing else, not even 0 or 1.
@pwnwriter Жыл бұрын
10:40 You didn't see the original documentation 🙊 Nvm
@isaacslemko7947 Жыл бұрын
The fact that I taught myself binary to a T when I was 10, makes this so much easier
@mister_byte_8 ай бұрын
musturd
@fireplank75202 жыл бұрын
Hi! you accidentally leaked every video by linking it at the end lol. oops!
@bombrman1994 Жыл бұрын
If parimagen heard u call it mutt he will be pissed
@antilogism11 ай бұрын
I figured you were referencing Mutt's creator but that's Michael Elkins. Who's Parimagen?
@bombrman199411 ай бұрын
@@antilogism primagen 😅
@kazuhah1743 Жыл бұрын
not that it matters much, but tuple is pronounced tewple, "ew" as in new
@Itzcrystalroblox Жыл бұрын
i... understood nothing, maybe is my english problem
@bil4x467 Жыл бұрын
Time hates semicolons :p
@LamYipMing Жыл бұрын
The way you miss semicolon every time you type is very irritating
@stuvius9 ай бұрын
I also hate semicolons
@patricklittle1002 Жыл бұрын
Lol about semicolons - the most normal muscle memory to do and he omits it