<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:schema="http://schema.org/" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" version="2.0" xml:base="https://www.linuxjournal.com/">
  <channel>
    <title>Rust</title>
    <link>https://www.linuxjournal.com/</link>
    <description/>
    <language>en</language>
    
    <item>
  <title>Getting Started with Rust: Working with Files and Doing File I/O</title>
  <link>https://www.linuxjournal.com/content/getting-started-rust-working-files-and-doing-file-io</link>
  <description>  &lt;div data-history-node-id="1340126" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/mihalis-tsoukalos" lang="" about="https://www.linuxjournal.com/users/mihalis-tsoukalos" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Mihalis Tsoukalos&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;&lt;em&gt;How to develop command-line utilities in Rust.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;
This article demonstrates how to perform basic file and file
I/O operations in Rust, and also introduces Rust's ownership concept and the Cargo tool.
If you are seeing Rust code for the first time, this article should provide
a pretty good idea of how Rust deals with files and file I/O, and if you've
used Rust before, you still will appreciate the code
examples in this article.
&lt;/p&gt;

&lt;span class="h3-replacement"&gt;
Ownership&lt;/span&gt;

&lt;p&gt;
It would be unfair to start talking about Rust without first discussing
ownership. Ownership is the Rust way of the developer having
control over the lifetime of a variable and the language in order to be safe.
Ownership means that the passing of a variable also passes the ownership
of the value to the new variable.
&lt;/p&gt;

&lt;p&gt;
Another Rust feature
related to ownership is borrowing. Borrowing is about
taking control over a variable for a while and then returning that
ownership of the variable back. Although borrowing allows you to have
multiple references to a variable, only one reference can be mutable
at any given time.
&lt;/p&gt;

&lt;p&gt;
Instead of continuing to talk theoretically about ownership and
borrowing, let's look at a code example
called &lt;code&gt;ownership.rs&lt;/code&gt;:

&lt;/p&gt;&lt;pre&gt;
&lt;code&gt;
fn main() {
    // Part 1
    let integer = 321;
    let mut _my_integer = integer;
    println!("integer is {}", integer);
    println!("_my_integer is {}", _my_integer);
    _my_integer = 124;
    println!("_my_integer is {}", _my_integer);

    // Part 2
    let a_vector = vec![1, 2, 3, 4, 5];
    let ref _a_correct_vector = a_vector;
    println!("_a_correct_vector is {:?}", _a_correct_vector);

    // Part 3
    let mut a_var = 3.14;
    {
        let b_var = &amp;mut a_var;
        *b_var = 3.14159;
    }
    println!("a_var is now {}", a_var);
}
&lt;/code&gt;
&lt;/pre&gt;


&lt;p&gt;
So, what's happening here? In the first part, you define an integer
variable (&lt;code&gt;integer&lt;/code&gt;) and create a mutable variable based on
&lt;code&gt;integer&lt;/code&gt;. Rust performs a full copy for primitive data types because
they are cheaper, so in this case, the &lt;code&gt;integer&lt;/code&gt; and
&lt;code&gt;_my_integer&lt;/code&gt; variables
are independent from each other.
&lt;/p&gt;

&lt;p&gt;
However, for other types, such as a vector, you aren't allowed to change
a variable after you have assigned it to another variable.
Additionally, you should use a reference for the
&lt;code&gt;_a_correct_vector&lt;/code&gt;
variable of Part 2 in the above example, because Rust won't make a copy of
&lt;code&gt;a_vector&lt;/code&gt;.
&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/getting-started-rust-working-files-and-doing-file-io" hreflang="en"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Thu, 20 Jun 2019 11:30:00 +0000</pubDate>
    <dc:creator>Mihalis Tsoukalos</dc:creator>
    <guid isPermaLink="false">1340126 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>Text Processing in Rust</title>
  <link>https://www.linuxjournal.com/content/text-processing-rust</link>
  <description>  &lt;div data-history-node-id="1340474" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/mihalis-tsoukalos" lang="" about="https://www.linuxjournal.com/users/mihalis-tsoukalos" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Mihalis Tsoukalos&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;&lt;em&gt;Create handy command-line utilities in Rust.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;
This article is about text processing in Rust, but it also contains a
quick introduction to pattern matching, which can be very handy when
working with text.
&lt;/p&gt;

&lt;p&gt;
Strings are a huge subject in Rust, which can be easily realized by
the fact that Rust has two data types for representing strings as well
as support for macros for formatting strings. However, all of this also
proves how powerful Rust is in string and text processing.
&lt;/p&gt;

&lt;p&gt;
Apart from covering some theoretical topics, this article shows how to develop
some handy yet easy-to-implement command-line utilities that let you
work with plain-text files. If you have the time, it'd be great to
experiment with the Rust code presented here, and maybe develop your own
utilities.
&lt;/p&gt;

&lt;span class="h3-replacement"&gt;
Rust and Text&lt;/span&gt;

&lt;p&gt;
Rust supports two data types for working with strings: &lt;code&gt;String&lt;/code&gt;
and &lt;code&gt;str&lt;/code&gt;.
The &lt;code&gt;String&lt;/code&gt; type is for working with mutable strings that
belong to you, and it has length and a capacity property. On the other
hand, the &lt;code&gt;str&lt;/code&gt; type is for working with immutable strings that you want
to pass around. You most likely will see an &lt;code&gt;str&lt;/code&gt; variable be used as
&lt;code&gt;&amp;str&lt;/code&gt;. Put simply, an &lt;code&gt;str&lt;/code&gt; variable is accessed as a reference to some
UTF-8 data. An &lt;code&gt;str&lt;/code&gt; variable is usually called a "string slice" or, even
simpler, a "slice". Due to its nature, you can't add and remove any
data from an existing &lt;code&gt;str&lt;/code&gt; variable. Moreover, if you try to call the
&lt;code&gt;capacity()&lt;/code&gt; function on an &lt;code&gt;&amp;str&lt;/code&gt; variable, you'll get an error message
similar to the following:

&lt;/p&gt;&lt;pre&gt;
&lt;code&gt;
error[E0599]: no method named `capacity` found for type
 ↪`&amp;str` in the current scope
&lt;/code&gt;
&lt;/pre&gt;


&lt;p&gt;
Generally speaking, you'll want to use an &lt;code&gt;str&lt;/code&gt; when you want to pass a string
as a function parameter or when you want to have a read-only version
of a string, and then use a &lt;code&gt;String&lt;/code&gt; variable when you want to have a mutable
string that you want to own.
&lt;/p&gt;

&lt;p&gt;
The good thing is that a function that accepts &lt;code&gt;&amp;str&lt;/code&gt; parameters can
also accept &lt;code&gt;String&lt;/code&gt; parameters. (You'll see such an example in the
&lt;code&gt;basicOps.rs&lt;/code&gt; program presented later in this article.)
Additionally, Rust supports the &lt;code&gt;char&lt;/code&gt; type, which is for representing
single Unicode characters, as well as string literals, which are
strings that begin and end with double quotes.
&lt;/p&gt;

&lt;p&gt;
Finally, Rust supports what is called a &lt;code&gt;byte&lt;/code&gt; string. You can define a new
&lt;code&gt;byte&lt;/code&gt; string as follows:

&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/text-processing-rust" hreflang="en"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Mon, 18 Mar 2019 13:07:07 +0000</pubDate>
    <dc:creator>Mihalis Tsoukalos</dc:creator>
    <guid isPermaLink="false">1340474 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>Linux Journal October 2018: Programming</title>
  <link>https://www.linuxjournal.com/content/new-issue-out-linux-journal-october-2018-programming</link>
  <description>  &lt;div data-history-node-id="1340169" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/carlie-fairchild" lang="" about="https://www.linuxjournal.com/users/carlie-fairchild" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Carlie Fairchild&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p lang="x-size-14" xml:lang="x-size-14" xml:lang="x-size-14"&gt;Welcome to the Programming issue, October 2018, of &lt;em&gt;Linux Journal&lt;/em&gt;. This month we highlight programming languages new and old including Go, Rust, Clojure and Bash. Take a look at this month's complete line-up:&lt;/p&gt;

&lt;p lang="x-size-14" xml:lang="x-size-14" xml:lang="x-size-14"&gt;Featured articles in this issue include:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;a href="https://www.linuxjournal.com/content/understanding-bash-elements-programming"&gt;Understanding Bash: Elements of Programming&lt;/a&gt;** &lt;em&gt;This article is available online now as a sneak peak in to our October issue.&lt;/em&gt;&lt;/li&gt;
	&lt;li&gt;Getting Started with Rust: Working with Files and Doing File I/O&lt;/li&gt;
	&lt;li&gt;Introductory Go Programming Tutorial&lt;/li&gt;
	&lt;li&gt;Creating Linux Command-Line Tools in Clojure&lt;/li&gt;
&lt;/ul&gt;&lt;p lang="x-size-14" xml:lang="x-size-14" xml:lang="x-size-14"&gt;Additional articles:&lt;/p&gt;

&lt;ul&gt;&lt;li lang="x-size-14" xml:lang="x-size-14" xml:lang="x-size-14"&gt;Shall We Study Amazon's Pricing Together?&lt;/li&gt;
	&lt;li lang="x-size-14" xml:lang="x-size-14" xml:lang="x-size-14"&gt;Review: System76 Oryx Pro Laptop&lt;/li&gt;
	&lt;li lang="x-size-14" xml:lang="x-size-14" xml:lang="x-size-14"&gt;3D-Printed Firearms Are Blowing Up&lt;/li&gt;
	&lt;li lang="x-size-14" xml:lang="x-size-14" xml:lang="x-size-14"&gt;FOSS Project Spotlight: Tutanota, the First Encrypted Email Service with an App on F-Droid&lt;/li&gt;
	&lt;li lang="x-size-14" xml:lang="x-size-14" xml:lang="x-size-14"&gt;Introducing Genius, the Advanced Scientific Calculator for Linux&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Columns:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Kyle Rankin's Hack and /: Papa's Got a Brand New NAS: the Software&lt;/li&gt;
	&lt;li&gt;Shawn Powers' The Open-Source Classroom: Have a Plan for Netplan&lt;/li&gt;
	&lt;li&gt;Reuven M. Lerner's At the Forge: Automate Sysadmin Tasks with Python's os.walk Function&lt;/li&gt;
	&lt;li&gt;Dave Taylor's Work the Shell: Normalizing Filenames and Data with Bash&lt;/li&gt;
	&lt;li&gt;Zack Brown's diff -u: What's New in Kernel Development&lt;/li&gt;
	&lt;li&gt;Glyn Moody's Open Sauce: Now Is the Time to Start Planning for the Post-Android World&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Subscribers&lt;/strong&gt;, you can &lt;a href="https://secure2.linuxjournal.com/pdf/dljdownload.php"&gt;download your October issue&lt;/a&gt; now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not a subscriber?&lt;/strong&gt; It’s not too late. &lt;a href="http://www.linuxjournal.com/subscribe"&gt;Subscribe today&lt;/a&gt; and receive instant access to this and ALL back issues since 1994!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Want to buy a single issue?&lt;/strong&gt; Buy the August magazine or other single back issues &lt;a href="https://store.linuxjournal.com/collections/back-issues-of-linux-journal/products/august-2018-issue-of-linux-journal"&gt;in the &lt;em&gt;LJ&lt;/em&gt; store&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/new-issue-out-linux-journal-october-2018-programming" hreflang="en"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Mon, 01 Oct 2018 14:59:55 +0000</pubDate>
    <dc:creator>Carlie Fairchild</dc:creator>
    <guid isPermaLink="false">1340169 at https://www.linuxjournal.com</guid>
    </item>

  </channel>
</rss>
