Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
EnumMatching.rs
LiteralMatching.rs
MatchingEnumValues.rs
README.md
atPattern.rs
dereferencingInPatterns.rs
extractingValuesFromNestedStructsAndEnums.rs
extractingValuesFromStructs.rs
extractingValuesFromTuples.rs
ignoringValuesInPatterns.rs
ignoringValuesInStructs.rs
patternGuards.rs
rangePatterns.rs
simpleProgramBySwitch.c
usingMultiplePatterns.rs

README.md

Examples of Patterns in Rust

There are different examples of patterns in Rust programming language.

Below files are associated with Rust turorial episode No 14 in Persian:

switch case

Example of C switch case is in the simpleProgramBySwitch.c file and corresponding example of this program in Rust is in the LiteralMatching.rs file.

Matching Simple Enums

Example of matching simple enum values is in the EnumMatching.rs file

Matching Values of Enums

Example of matching values of enums is in the MatchingEnumValues.rs file.

Using Ranges as Patterns

Example of using ranges in patterns is in teh rangePatterns.rs file.

Using Multiple Patterns

Example of using multiple patterns in a single match arm is in the usingMultiplePatterns.rs file.

Extracting Values of Tuples

Example of extracting values from tuples with patterns is in the extractingValuesFromTuples.rs file.

Extracting Values of Struct

Example of extracting values from structs with patterns is in the extractingValuesFromStructs.rs .

Extracting Values from Nested Structs and Enums

Example of extracting values of nested structs and enums is in the extractingValuesFromNestedStructsAndEnums.rs file.

Dereferencing in Patterns

Example of dereferencing in patterns is in the dereferencingInPatterns.rs file.

Ignoring Values

Example of ignoring values in the input tuple is in the ignoringValuesInPatterns.rs file.

Ignoring Values of Structs

Example of ignoring values of structs in the patterns is in the ignoringValuesInStructs.rs file.

Guards

Example of pattern guards is in the patternGuards.rs file.

@ Pattern

Example of @ operator in patterns is in the atPattern.rs file.

You can’t perform that action at this time.