# Exercism -> (Rust, Sublist)

By [Solomon](https://paragraph.com/@solomon-4) · 2022-07-04

---

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](http://exercism.org/). Hope this will help someone!

In short, the answer:

[_click to see the code_](https://exercism.org/tracks/rust/exercises/sublist/iterations?idx=1)

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!

---

*Originally published on [Solomon](https://paragraph.com/@solomon-4/exercism-rust-sublist)*
