Odak modu
Enums
An enum is a data structure in Rust that defines its different subtypes. Provides the same functionality as a struct, but with fewer code. Enum is commonly used for developing programs in Solana, since we can create custom types for our purpose.
The example given in the Rust documentation allows us to better understand these structures:
Whereas structs allow you to bring together related fields and data, such as a Rectangle with its width and height, enums allow you to specify a value as one of a potential set of values. For example, we may state that Rectangle is one of several conceivable forms, along with Circle and Triangle. Rust allows us to achieve this by encoding these possibilities as an enum.
You can find detailed further information from Rust Official documentation:
https://doc.rust-lang.org/book/ch06-00-enums.html
Patterns and Matching
In Rust, patterns are a particular syntax for matching against the structure of types, both complicated and simple. Using patterns in combination with match expressions and other structures provides you greater control over the control flow of a program.
Per Rust official documentation a pattern consists of some combination of the following:
Pattern components describe the shape of data. The program compares values to patterns to determine whether it has the necessary data structure to continue running a certain piece of code. We apply a pattern by comparing it to a value. If the pattern matches the value, the value portions are used in our code. If it does not, the code associated with the pattern will not be executed.
You can find detailed further information from Rust Official documentation:
https://doc.rust-lang.org/book/ch18-00-patterns.html
Resources:
https://www.educative.io/answers/what-is-an-enum-in-rust
https://www.buraksenyurt.com/post/C-Temelleri-Enum-Sabitinin-Bilinmeyen-Yonleri-bsenyurt-com-dan
Sektörde en çok aranan yazılım becerilerini kazan
Yapay zeka desteği, birebir mentörlük saatleri, canlı dersler ve senin için özel hazırlanmış içeriklerle eksiklerini tamamla, düzenli geri bildirimler al ve öğrenme sürecini en verimli hale getir.
Yunus Emre Kabakcı
Patika+ mezunuPatika+ Fullstack Web Development Bootcamp mezunumuz Yunus Emre,
3 ay içinde Katar’dan aldığı teklif ile, global bir şirket olan Pavo Group’da işe başladı!
“İçerik zenginliği, mentor desteği, ileriye dönük bir network sağlaması ve dünyada en çok tercih edilen frameworkler üzerinden bir eğitim veriyor olması Patika+’ı tercih etmemin temel sebepleri oldu!“
Yorum yapabilmek için derse kayıt olmalısın!