Hi Ricky, I watch every day one of your videos before starting to work with my morning coffee. You are so sympathetic and knowledgeable! Thanks a lot for the content!
In my project I had to keep everything inside the "src" folder, without any more nesting. Because when there were more nests, the local code worked normally, but in my github actions jobs it gave an error that didn't find the imports...
If I understand correctly: use crate::xxx.yyy; use super::xxx.yyy; use self::xxx.yyy; Is intended for code within your create itself:. When you use crates outside your code you just use use :xxx.yyy; And specify it in the cargo [dependencies] xxx = { path = "../xxx"} New to Rust and I was convinced that use crate::xxx was intended for code that was in a different crate to point to code in that different crate. Lost many hours with trial and error until I found this post :-)
Something else that is confusing from someone that is coming from another language: use crate::xxx.yyy; use super::xxx.yyy; use self::xxx.yyy; "super" and "self" is not what you expect how it behaves. When you look at the folder structure then the file is at the same level as your source code and you want to use:. use self::xxx.yyy; However you need to use instead. use super::xxx.yyy; Probably because in Rust your filename is also a namespace deeper. Most other languages, the filename itself is not part of a namespace but in Rust it is
Hi Ricky, I watch every day one of your videos before starting to work with my morning coffee. You are so sympathetic and knowledgeable!
Thanks a lot for the content!
Your content is too professional for a channel with 400 subs. You deserve atleast 25K. Great job!
Very good overview, thanks!
In my project I had to keep everything inside the "src" folder, without any more nesting. Because when there were more nests, the local code worked normally, but in my github actions jobs it gave an error that didn't find the imports...
What plug-in gives you that yellow line underneath your “mod” definition and the down the left side?
If I understand correctly:
use crate::xxx.yyy;
use super::xxx.yyy;
use self::xxx.yyy;
Is intended for code within your create itself:.
When you use crates outside your code you just use
use :xxx.yyy;
And specify it in the cargo
[dependencies]
xxx = { path = "../xxx"}
New to Rust and I was convinced that use crate::xxx was intended for code that was in a different crate to point to code in that different crate. Lost many hours with trial and error until I found this post :-)
Please provide
the repo link
Amazing!
I was hoping this video went into additional examples and explanations instead of reiterating the content that's in the rust lang book.
Ɛ >
Rust rocks 😁
Something else that is confusing from someone that is coming from another language:
use crate::xxx.yyy;
use super::xxx.yyy;
use self::xxx.yyy;
"super" and "self" is not what you expect how it behaves.
When you look at the folder structure then the file is at the same level as your source code and you want to use:.
use self::xxx.yyy;
However you need to use instead.
use super::xxx.yyy;
Probably because in Rust your filename is also a namespace deeper.
Most other languages, the filename itself is not part of a namespace but in Rust it is