Комментарии:
Coming from c++ this is intuitive. Unique pointers and move semantics give this type of behavior as options in modern c++ so having them as the default makes sense. Also having the const as default on refs is another good safety measure. I do think a basic understanding of pointers in c and references and smart pointers in c++ will help people understandownership and the ideas it's built upon.
ОтветитьThis is so confusing. I will have to get back to this later.
ОтветитьHow/where are u executing a()?
ОтветитьThis is BY FAR the hardest part to learn Rust. It's frustrating to learn without any C background tbh.
ОтветитьIn C++ you use std::unique_ptr and it auto-deletes when out of scope. Use of `new` is practically deprecated at this point.
ОтветитьI dunno, this seems like a pile of malarkey when proper message passing mechanism could be created in any language.
ОтветитьThanks for the great website hosting info! Ive examined DreamHost and A2 Web Hosting, but Cloudways with TST20 coupon is the real gem.
Ответить"Get them tattooed, whatever it takes."
Don't threaten me with a good time buddy.
Can you help the beginner? Is there a possibility for borrow-checker to help to control partial structure updates? I mean can I pass the whole structure to the functions and in&out but borrow checker could help/nag in case called function changed a field value but the rest of the caller function code assumes the value has not been changed/updated? Can you show an example for the structure with the basic u32/int fields?
ОтветитьI read the book and i was overwhelmed of new terms and information. this video helped me to visualize it live. yes rust book visualizations were great but for me i find this more helpful. i think after watching this, i will understand the book better. thank you.
there are too little learning resources for rust :)
daning kruger the video
ОтветитьI am going to watch this every day until I understand it in my bones
Ответитьwell, this one is not easy to understand. 😭
ОтветитьWhat is this b here ----- > if item == b' ' {
return i;
}
In C we have special memory (read only memory ) where string literlas are stored apart from stack and heap?
Do we have similar thing in rust (you mentioned string literals are stored in the binary ?)
could you help me out?
finally learning rust 💙
Ответитьis it a move or copy ? = is it a copy type or not ? = does it implement the copy trait or not ?
ОтветитьWhat I really like about your videos, until now :-), is the speed, you tell things. I'm not native American or English, but most every tutorial I watched for instance on Udemy was so slow. Of cause someone can speedup the video, but sometimes, the speaker speaks faster or changes slides, and that results in confusion.
Very, very well done, again until here 🙂as I don't know more of your videos besides the seen ones.
You do not explain specifically weather `&str` string slice or string literal is taken ownership by a function when it(the slice) enters it(the function). But I suppose the function does not take ownership because of `&` symbol.
ОтветитьOh, this is VERY confusing if you are used to Python style of GC and you "just write code on the fly that works", no planning. Python and PHP encourages that kind of experimentation. When you get an error in Python it's always about the CURRENT line. And sometimes you get bugs without errors, like when you learn
What's helping me is: not trying to force rote memorization of 100% of this chapter. This isn't school where if you fail this chapter you are guaranteed to fail the next chapter. Just make sure you understand that Rust is performing static analysis. It's finding bugs that might never ever get triggered in your code, but could happen once someone else adds an innocent line of code later on (and now you get paged at 3AM).
If you understood enough of this to explain it on an elevator ride (quick and high level), maybe move on, you can always revisit this. Getting a compiler error later on isn't going to be total failure. I bet some people learn that way even though they tried to avoid it.
restriction
Ответитьjust wow
ОтветитьI asked chatgpt and it said that s2 points to the memory of the data of s1 instead of pointing to s1 and that the metdata of the string is stored in the heap can anyone enlighten me?
ОтветитьBrilliant explanation. Thank you.
Ответитьif you cannot remember the ownership rules then here is small trick i thought of which was :-
1) each house has a one owner
2) each house can have only one owner at a time
3) when owner dies the house is broken
Thank you very much!
ОтветитьSlower write time than C++? I'm not learning rust because C++ isn't safe. I don't need help writing safe code. I'm learning Rust because I'm hoping I'll end up being able to get high performance software working in much less time than I can with C++.
I have a hypothesis about why it takes longer to create programs in C++ (for example) than it does in C# (for example) that is maybe a bit different from what most people seem to think.
It's illustrated by a story from experience. I was working on a game development project and I wanted to stream an .mp3 directly from an encrypted zip file. While working in C++, I found myself struggling with obscure errors and problems with the libraries I was using. I tried switching out libraries, switching my encryption and compression methods, I tried everything short of learning how to do encryption and compression and mp3 decoding from scratch myself to fix the problem.
After 2 or 3 weeks of this, I remembered a time when I was working at Intel. I once worked in a project group in which there was a developer working on getting a media viewer going. He was working in C++ and struggling with problems with libraries while working with the combination of compression, encryption, and audio/visual decoding. After 3 months, he still did not have it working. I joined that team near the end of it's multi-year effort. 6 or 8 months into my tenure on it, the team was disbanded and a separate group was given the project, who had been working on the same software in C# and had managed to get a working version together in about 4 months. (The whole thing, not just the audio-visual part.)
So I tried to get streaming this .mp3 from an encrypted zip file working in C#. Within a matter of hours I had it working. I was able to switch encryption and compression methods around and it still worked fine. No significant problems.
This really had nothing at all to do with syntax or memory management or borrow checking or anything at all like any of that! It was simply a matter of not struggling for weeks or months with obscure problems with external dependencies. That's it.
So I'm hoping that my code will perform at close to the speed of C++ and that when I go to use Rust packages, I'll find what I need, and I won't struggle with obscure problems with them for weeks or months on end. I don't care if it takes me a few minutes longer to write a function or a struct/class etc. I care if it takes me weeks or months longer to get functionality supposedly provided by external dependencies working.
Years ago I was scared off of Rust by the borrow checker and such, but was recently convinced to take another look when you said "These libraries aren't abandoned - they're Done." Yes, yes! And hopefully they actually work as advertised. This is what I'm hoping for from Rust.
I'm tempted to make this a Quora post. After I finish the early part of the learning process, maybe the first thing I'll do is try to get streaming an .mp3 directly from an encrypted zip file working in Rust and see how long it takes me. If I can do it in 3 days or less, I'll post this story to Quora, and mention your extremely helpful channel. (Thanks so much for doing this, by the way!)
I was worried learning Rust, but more I look at this. THIS MAKES SO MUCH SENSE!
ОтветитьWhich extensions you are using in vscode?
ОтветитьThis is by far the toughest part of Rust. I really wish the book had a ton more examples and explained things far better.
ОтветитьIf I may
Very good video! but your voice makes me sleep :( ...
Hey! Love the videos, thanks so much for producing and sharing these!
Just wanted to let you know that the flag in the background is backwards. Should always be displayed with the starts in the top left, even when displayed vertically!
Thank you for making this. It's so helpful and so easy to follow along. You're amazing
ОтветитьWhat is a Shtring?
ОтветитьI love you, This is awesome.
ОтветитьVideo form of the book helps me so much, I read really slow, you covered the entire chapter in 25 min shorter than I could probably read it lol.
Ответитьin the Stack & Heap section, why was "hello" not stored in heap?
ОтветитьThis is the best explanation,
I have come across.
Now as mojo is new cool language that's easy to learn, safe and fast on bare metal, and entered TIOBE Top 50 index, Rust needs to offer something new lol
Some game programmers attached to 6502, Z80, and 68000 Assembly say C is slow and leads to messy code. C developers then criticize C++. I think garbage collection has its place in games—just look at Minecraft and Roblox. With hardware improving, latency and RAM wasn’t the major issue it once was. Languages like C, Rust, and Zig serve very very specialized purposes, but the fixation on keeping latency under 0.1 seconds seems a bit overblown. In many real-world scenarios, network delays and task scheduling usually take longer. Manual memory management might be important for real-time systems, but it feels less relevant for typical personal computing. I also see some challenges with Rust. Cargo piles on dependencies for very simple programs, and the borrow checker adds cost on compile times. Adjusting to ownership and borrowing concepts is something I also consider as cost. Rust is definitely not zero cost in absolute sense
You forgot about one memory management model! Pure functional immutability, where everything is on the stack and passed by value.
ОтветитьI am new to Rust, read ownership chapter twice, got the concepts of ownership, reference and moves but still wasn't confident. This video did the trick and made everything crystal clear. Thanks a ton!
Ответить