<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Rustlang on My Notes</title><link>https://harryho.github.io/coding/rustlang/</link><description>Recent content in Rustlang on My Notes</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://harryho.github.io/coding/rustlang/index.xml" rel="self" type="application/rss+xml"/><item><title>Data Types &amp; Ownership</title><link>https://harryho.github.io/coding/rustlang/rust-note-1/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://harryho.github.io/coding/rustlang/rust-note-1/</guid><description>&lt;h3 id="mutability"&gt;Mutability&lt;a class="anchor" href="#mutability"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Rust encourages you to favor immutability. It’s important that we get compile-time errors when we attempt to change a value that we previously designated as immutable because this very situation can lead to bugs.&lt;/p&gt;
&lt;p&gt;But mutability can be very useful. To make them mutable is simply adding mut in front of the variable name. In addition to allowing this value to change, mut conveys intent to future readers of the code by indicating that other parts of the code will be changing this variable value.&lt;/p&gt;</description></item><item><title>Project, Vector, String &amp; Hashmap</title><link>https://harryho.github.io/coding/rustlang/rust-note-2/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://harryho.github.io/coding/rustlang/rust-note-2/</guid><description>&lt;h3 id="project-management"&gt;Project management&lt;a class="anchor" href="#project-management"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Rust has a number of features that allow you to manage your code’s organization, including which details are exposed, which details are private, and what names are in each scope in your programs.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Packages: A Cargo feature that lets you build, test, and share crates&lt;/li&gt;
&lt;li&gt;Crates: A tree of modules that produces a library or executable&lt;/li&gt;
&lt;li&gt;Modules and use: Let you control the organization, scope, and privacy of paths&lt;/li&gt;
&lt;li&gt;Paths: A way of naming an item, such as a struct, function, or module&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="package--crate"&gt;Package &amp;amp; Crate&lt;a class="anchor" href="#package--crate"&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A package is one or more crates that provide a set of functionality. A package contains a Cargo.toml file that describes how to build those crates.&lt;/p&gt;</description></item><item><title>Error handling</title><link>https://harryho.github.io/coding/rustlang/rust-note-3/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://harryho.github.io/coding/rustlang/rust-note-3/</guid><description>&lt;h3 id="error"&gt;Error&lt;a class="anchor" href="#error"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Rust groups errors into two major categories: recoverable and unrecoverable errors.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Rust doesn’t have exceptions. Instead, it has the type Result&amp;lt;T, E&amp;gt; for recoverable errors and the panic! macro that stops execution when the program encounters an unrecoverable error.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="panic---unrecoverable-errors"&gt;panic! - Unrecoverable Errors&lt;a class="anchor" href="#panic---unrecoverable-errors"&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Rust has the panic! macro. When the panic! macro executes, your program will print a failure message, unwind and clean up the stack, and then quit. This most commonly occurs when a bug of some kind has been detected and it’s not clear to the programmer how to handle the error.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="unwinding-the-stack-or-aborting-in-response"&gt;Unwinding the Stack or Aborting in Response&lt;a class="anchor" href="#unwinding-the-stack-or-aborting-in-response"&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;By default, when a panic occurs, the program starts unwinding, which means Rust walks back up the stack and cleans up the data from each function it encounters. But this walking back and cleanup is a lot of work. The alternative is to immediately abort, which ends the program without cleaning up. Memory that the program was using will then need to be cleaned up by the operating system.&lt;/p&gt;</description></item><item><title>Generic Type &amp; Trait</title><link>https://harryho.github.io/coding/rustlang/rust-note-4/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://harryho.github.io/coding/rustlang/rust-note-4/</guid><description>&lt;h3 id="generic-type"&gt;Generic Type&lt;a class="anchor" href="#generic-type"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Generics are abstract stand-ins for concrete types or other properties. When we’re writing code, we can express the behavior of generics or how they relate to other generics without knowing what will be in their place when compiling and running the code.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="removing-duplication-by-extracting-a-function"&gt;Removing Duplication by Extracting a Function&lt;a class="anchor" href="#removing-duplication-by-extracting-a-function"&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;steps we took to change the duplication code :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Identify duplicate code.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Extract the duplicate code into the body of the function and specify the inputs and return values of that code in the function signature.&lt;/p&gt;</description></item></channel></rss>