Skip to content

A curated set of Rust code snippets demonstrating key language features, from basic conditionals to loops. Ideal for quick reference and learning essentials. 🦀

Notifications You must be signed in to change notification settings

0xSaksham/branches

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Code Showcase

This repository contains a collection of Rust code snippets that demonstrate various concepts in the Rust programming language. The code covers topics such as conditional statements, loops, and control flow. Let's explore what each section entails:

1. Simple Conditional Statement

The main function begins with a basic conditional statement that checks if a number is less than 5 and prints either "True" or "False" accordingly.

2. Else If Statement

The else_if function showcases an example of an "else if" statement. It determines whether a number is even or odd and prints the result.

3. If in Let Statement

The if_in_let function demonstrates the usage of the if statement within a let statement, showcasing Rust's expressive syntax.

4. Infinite Loop

The infinite_loop function contains a loop that runs indefinitely, demonstrating how to create an infinite loop and stop it using CTRL+C in the terminal.

5. Using Continue in a Loop

The use_continue function exhibits the continue keyword in a for loop, skipping even numbers and printing only the odd ones.

6. Value from Loop

In the value_from_loop function, a loop accumulates a counter until it reaches 10, then breaks, returning the counter multiplied by 2.

7. Named Loops

The named_loops function showcases nested loops, including a named loop ('counting_up), breaking out of the outer loop based on specific conditions.

8. While Loop

The while_loop function illustrates a simple while loop that counts down from 3 to 0, printing the current number in each iteration.

Feel free to explore, modify, and use these code snippets as a reference for learning Rust programming concepts. If you have any questions or improvements, please don't hesitate to contribute or open an issue.

Happy coding in Rust! 🦀

About

A curated set of Rust code snippets demonstrating key language features, from basic conditionals to loops. Ideal for quick reference and learning essentials. 🦀

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages