4th year CS Student. Interested in Blockchain, wannabe proficient in Rust. Forgot to keep updating my linkedIn for a year, hope my care
4th year CS Student. Interested in Blockchain, wannabe proficient in Rust. Forgot to keep updating my linkedIn for a year, hope my care
Subscribe to Solomon
Subscribe to Solomon
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers
I will try to explain you how I am taking my time to get comfortable with rust. Before, I thought copy-paste was the way to go. Right now, i am thoroughly spending time to understand how the language works.
I will try to make it a series of solutions/explanations of exercises on exercism. Hope this will help someone!
In short, the answer:
Here are some things I learned (dyor):
PartialEq -> Trait
Trait -> Collection of Methods (can access other methods in the trait + of the object that the trait is applied
Traits methods can also be overriden
sublist<T: PartialEq> means a function that accept a generic type with the boundaries of the PartialEq.
what is a generic type? ->
struct apple {};
struct fruit(apple);
here, fruit is a concrete type, apple is not generic, so the apple struct should be passed only. Another example:
struct apple {};
struct fruit(apple);
here, anything can be passed, because fruit struct is of the generic type.
rust allows to define functions inside functions.
array2.windows( length ) divides an array into chunks ( mini arrays ) that are of the size length. Every possible sublist is created from array. Then all of the sublists are compared with .any(|x| x == array1). here we are simply comparing if the arrays are identical.
That’s it for this time, if u have any questions please let me know!
I will try to explain you how I am taking my time to get comfortable with rust. Before, I thought copy-paste was the way to go. Right now, i am thoroughly spending time to understand how the language works.
I will try to make it a series of solutions/explanations of exercises on exercism. Hope this will help someone!
In short, the answer:
Here are some things I learned (dyor):
PartialEq -> Trait
Trait -> Collection of Methods (can access other methods in the trait + of the object that the trait is applied
Traits methods can also be overriden
sublist<T: PartialEq> means a function that accept a generic type with the boundaries of the PartialEq.
what is a generic type? ->
struct apple {};
struct fruit(apple);
here, fruit is a concrete type, apple is not generic, so the apple struct should be passed only. Another example:
struct apple {};
struct fruit(apple);
here, anything can be passed, because fruit struct is of the generic type.
rust allows to define functions inside functions.
array2.windows( length ) divides an array into chunks ( mini arrays ) that are of the size length. Every possible sublist is created from array. Then all of the sublists are compared with .any(|x| x == array1). here we are simply comparing if the arrays are identical.
That’s it for this time, if u have any questions please let me know!
No activity yet