Skip to content

CagriCatik/RUST

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Fundamentals

Rust Logo

Rust is a modern, statically-typed systems programming language that emphasizes safety, concurrency, and performance. This repository serves as a comprehensive guide to the fundamentals of Rust, covering everything from primitive data types to advanced concepts like ownership, borrowing, and control flow.

Table of Contents

  1. Primitive Data Types
  2. Compound Data Types
  3. Functions
  4. Ownership
  5. Borrowing & References
  6. Variables & Mutability
  7. Constants
  8. Shadowing
  9. Comments
  10. If-Else Statements - Control Flow
  11. Loops Control - Flow
  12. Structs
  13. Enums
  14. Error Handling Techniques
  15. Collection Types
  16. Projects

Getting Started

To get started with Rust, you'll need to install the Rust toolchain on your system. Once installed, you can compile and run Rust programs using the rustc compiler and the cargo build tool.

Here's the updated guide with the additional information on running Rust code directly with rustc:

Run the Rust Code

Using Cargo

  1. Create a New Rust Project:

    • Navigate to the directory where you want to create your project.

    • Use the cargo command to create a new project. For example, to create a project named hello_world, run:

      cargo new hello_world
    • This command creates a new directory named hello_world with a basic project structure.

  2. Build the Project:

    • In the project directory, run the following command to build your project:

      cargo build
    • This compiles your project and generates an executable in the target/debug directory.

  3. Run the Project:

    • To run the project, use the following command:

      cargo run
    • This will compile and run your project in one step, displaying the output.

Using rustc Directly

If you prefer not to use cargo, you can compile and run Rust code directly with rustc:

  1. Ensure Your Path is Set Up Correctly:
    • Since you just installed Rust, your shell might not have the updated PATH yet. To fix this, run:

      source $HOME/.cargo/env
    • To make this change permanent for future sessions, add the line to your shell's startup file (.bashrc, .zshrc, etc.):

      echo 'source $HOME/.cargo/env' >> ~/.bashrc
    • Then, reload your .bashrc file:

      source ~/.bashrc

Learning Resources

This guide is based on the excellent Bek Brace YouTube channel, which provides comprehensive video tutorials on Rust fundamentals. Additionally, you can refer to the official Rust Book and the Rust by Example for in-depth documentation and examples.

Conclusion

By following these steps, you should be able to set up, write, build, and run Rust code on your local machine. Rust's tooling, especially with cargo, makes managing projects and dependencies straightforward and efficient.

Releases

No releases published

Packages

No packages published