Introduction
In this lab, we explore the usage of the super
and self
keywords in Rust for removing ambiguity and avoiding hardcoded paths when accessing items.
Note: If the lab does not specify a file name, you can use any file name you want. For example, you can use main.rs
, compile and run it with rustc main.rs && ./main
.
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
rust(("Rust")) -.-> rust/MemorySafetyandManagementGroup(["Memory Safety and Management"])
rust(("Rust")) -.-> rust/DataStructuresandEnumsGroup(["Data Structures and Enums"])
rust(("Rust")) -.-> rust/DataTypesGroup(["Data Types"])
rust(("Rust")) -.-> rust/FunctionsandClosuresGroup(["Functions and Closures"])
rust/DataTypesGroup -.-> rust/type_casting("Type Conversion and Casting")
rust/FunctionsandClosuresGroup -.-> rust/function_syntax("Function Syntax")
rust/FunctionsandClosuresGroup -.-> rust/expressions_statements("Expressions and Statements")
rust/MemorySafetyandManagementGroup -.-> rust/lifetime_specifiers("Lifetime Specifiers")
rust/DataStructuresandEnumsGroup -.-> rust/method_syntax("Method Syntax")
subgraph Lab Skills
rust/type_casting -.-> lab-99335{{"Super and Self"}}
rust/function_syntax -.-> lab-99335{{"Super and Self"}}
rust/expressions_statements -.-> lab-99335{{"Super and Self"}}
rust/lifetime_specifiers -.-> lab-99335{{"Super and Self"}}
rust/method_syntax -.-> lab-99335{{"Super and Self"}}
end