Odak modu

Rust Fundamentals

Structs:Named-Field Structs

Structs are a collection of variables and work the same way that objects do in Javascript. You can declare a struct to have multiple properties and once you create a new struct, they will also have the same properties.

Structs in Rust allow you to create more complicated data types that have multiple properties. You can define your own type by creating a struct. A structure can also contain a structure in itself.

They are useful for grouping together related data.

Structs can be declared outside of a contract and imported into another contract. Generally, it is used to represent a record. To define a structure struct keyword is used, which creates a new data type.

There are 3 types of structs in Rust: named fields, tuple structs, and unit structs. 

  • Named field structs in Rust are typical C like structure. 
  • Tuple-like struct is similar to tuple in that the fields are unnamed but with additional functionality.
  • Unit-Like structs can be define without any fields. When you need to implement a trait on a type but don't have any data to place in the type itself, unit-like structs might be handy. 

To better understanding struct concept here are optional videos:

About tuple-like structs: https://www.youtube.com/watch?v=5z4CGI-uO9k 

About unit-like structs: https://www.youtube.com/watch?v=kuQMk8cRI4Q 

You can find detailed further information from Rust Official documentation:

https://doc.rust-lang.org/book/ch05-00-structs.html 

Resources:

https://www.geeksforgeeks.org/rust-concept-of-structures/ 

https://www.geeksforgeeks.org/solidity-enums-and-structs/ 


Background Pattern
Birlikte öğrenelim

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+ mezunu

Patika+ 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!“

Yorumlar

Yorum yapabilmek için derse kayıt olmalısın!