Rust In 8 Hours For Beginners Learn Coding Fast Ray Yao Copyright 2015 by Ray Yao All Rights Reserved Neither part of this book nor whole of this book may be reproduced or transmitted in any form or by any means electronic, photographic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without prior written permission from the author . All rights reserved ! Ray Yao About the Author : Ray Yao Certified PHP engineer by Zend, USA Certified JAVA programmer by Sun, USA Certified SCWCD developer by Oracle, USA Certified A+ professional by CompTIA, USA Certified ASP . NET expert by Microsoft, USA Certified MCP professional by Microsoft, USA Certified TECHNOLOGY specialist by Microsoft, USA Certified NETWORK+ professional by CompTIA, USA www . amazon . com/author/ray-yao Recommended Books by Ray Yao Advanced C++ In 8 Hours Advanced Java In 8 Hours AngularJs In 8 Hours Asp.Net Programming C# Exam C# Programming C++ Exam C++ Programming Dart In 8 Hours Data Science In 8 Hours Django In 8 Hours Git Github In 8 Hours Go In 8 Hours Html Css Exam Html Css Programming Java Exam Java Programming JavaScript Exam JavaScript Programming JQuery Exam JQuery Programming Jsp Servlets Programming Kotlin In 8 Hours Linux Command Line Linux Exam Lua In 8 Hours Machine Learning In 8 Hours Matlab In 8 Hours MySql Programming Node.Js In 8 Hours Numpy In 8 Hours Pandas In 8 Hours Perl In 8 Hours Php Exam Php MySql Programming PowerShell In 8 Hours Python Exam Python Programming R In 8 Hours React.Js In 8 Hours Ruby Programming Rust In 8 Hours Scala In 8 Hours Shell Scripting In 8 Hours Swift In 8 Hours TypeScript In 8 Hours Visual Basic Exam Visual Basic Programming Vue.Js In 8 Hours Xml Json In 8 Hours Preface Rust Programming in 8 Hours covers all essential Rust language knowledge . You can learn complete primary skills of Rust programming fast and easily .
The book includes more than 60 practical examples for beginners and includes tests & answers for the college exam, the engineer certification exam, and the job interview exam .
Note This book is only suitable for Rust beginners; it is not for the experienced Rust programmers.
Source Code for Download This book provides source code for download; you can download the source code for better study, or copy the source code to your favorite editor to test the programs . Table of Content
Hour 1
What is Rust Language?
Rust is a programming language developed by Mozilla that focuses on security and concurrency . The Rust language is jointly developed by the leader of the web language, Brendan Eich, Dave Herman, and Graydon Hoare of Mozilla . Rust is an excellent language for security, concurrency, and utility, for multi-core systems and absorbs important features of other dynamic languages such as : it doesnt need to manage memory, without Null Pointers, and so on . The Rust's syntax is similar to that of C++ . Rust is free open source software that is freely available to anyone and publicly shared so that people can also improve the design of the software .
The great feature of Rust language is the Security .
The Feature of Rust
- Rust uses the abstract functionality without affecting the runtime performance of the code
- Rust's error messages are clear and easy to understand, appear in a neat, color-coded format, and suggest spell checking in the program .
- Rust provides data-type checking functionality, which means it can automatically determine the type of an expression .
- Rust language can replace a copy operation with a move operation .
- Rust provides thread functionality without data contention .
- Rust uses the match pattern to better manage the program's control flow .
- Rust guarantees memory security by using the concept of ownership .
- Rust language can communicate with c language easily .
- Rust programmers can clearly control the memory allocation in release of memory locations and time .
Install Rust
(1) Install C++ Build Tools Before you install Rust, you must install C++ Build Tools .
- Click the following link to download C++ Build Tools :
- https : //visualstudio . microsoft . com/downloads/#build-tools-for-visual-studio-2017
- You can find :
- Click Download button on the right side, start downloading .
- After downloading the Build Toos installer, please install Build Tools for Visual Studio 2017
- During installation, select options that relate to C++ to install .
- After the installation is complete, please restart the computer .
(2) Install Rust If you have already installed Build Toos, then continue to install Rust . rust-lang . org/tools/install
- Please download the Rust installer RUSTUP-INIT.EXE .
- After downloading the rustup-init.exe installer, please double click it to install Rust .
- You can see the following message :
- Type , press Enter key to install Rust .
- When the installation is complete, please press Enter key to confirm .
(3) Rust Test Test Rust to check if the installation is successful . org/tools/install - Please download the Rust installer RUSTUP-INIT.EXE .
- After downloading the rustup-init.exe installer, please double click it to install Rust .
- You can see the following message :
- Type , press Enter key to install Rust .
- When the installation is complete, please press Enter key to confirm .
(3) Rust Test Test Rust to check if the installation is successful . The Rust working folder is C: \Users\Your_Name. For example, my Rust working folder is C: \Users\RAY. Rust working folder always includes three sub-folders : (1) . rustup folder, (2) . multirust folder, (3) . cargo folder .
Now we need to go to working folder first, and test Rust program . Please run cmd command, open the command line editor .
- Type cd\ to move to the root directory .
- Type cd \Users\Your_Name to move to the working folder .
- Run rustc --version command, you can see the output :
Congratulation ! The Rust installation is successful ! Note: In different Windows OS, the working folder is different . For example, your working folder may be C : \Users\Admin . Then you must find out the folder that contains three sub-folders . rustup folder, . multirust folder, . cargo folder) . cargo folder) . And make sure this folder as a working folder .
The First Rust Program
Please open the Notepad, and write the following code : Example 1.1
fn main() { println ! ("Hello, world ! "); } |
Save the file as hello . rs in the working folder, using . rs as extension name . Run cmd command, open the command line editor .
Output: Hello, world ! Explanation: fn main( ) defines a function named main . println ! () is a command used to output content . println ! () is a command used to output content .
The extension name of Rust file is . rs . Each statement ends with a semicolon ; cd\ moves to root directory . C : \>cd \Users\RAY moves to my working folder . rustc hello.rs compiles the Rust file hello . exe program .
Next page