Cannot move out of borrowed content

I don't understand the error cannot move out of borrowed content. I have received it many times and I have always solved it, but I've never understood why.

I don't understand the error cannot move out of borrowed content. I have received it many times and I have always solved it, but I've never understood why.

For example:

for line in self.xslg_file.iter() {
    self.buffer.clear();
for current_char in line.into_bytes().iter() {
    self.buffer.push(*current_char as char);
}

println!("{}", line);

}

produces the error:

error[E0507]: cannot move out of borrowed content
--> src/main.rs:31:33
|
31 | for current_char in line.into_bytes().iter() {
| ^^^^ cannot move out of borrowed content

I solved it by cloning line:

for current_char in line.clone().into_bytes().iter() {

I don't understand the error even after reading other posts like:

What is the origin of this kind of error?

The Rust developers should Know top 8 Rust IDE & text Editors

The Rust developers should Know top 8 Rust IDE & text Editors

Rust is an open source systems programming language which has been sponsored by Mozilla. It runs fast, claims to be safer than many other programming languages, prevents segfaults, practical in coding and a thread safety guaranteeing language

Apparently, a good Rust IDE & text editor must do two things very well: syntax highlighting (coloration of the code) and auto-completion.  Best choice of Rust IDE & editors can easily configure the working environment, leading to better productivity. let’s highlight 8 best Rust IDE & text editors for web developers and take a bird’s eye view of how each one of them can assist us when developing Rust applications.

Table of Contents

  • 1- IntelliJ rust
  • 2 – Eclipse RustDT
  • 3 – Atom Editor
  • 4 – Sublime text 3
  • 5- Visual studio code
  • 6- Neovim
  • 7 – GEANY
  • 8 – Spacemacs
1- IntelliJ rust

IntelliJ Rust is one of the most widely used Rust IDE. IntelliJ makes possible to link more then one project, even if you don’t use workspaces. There’s also a dedicated toolbar, which shows projects status. It provides all the mainly expected features including native code completion, broad navigation, intentions, formatting and much more.There’s also a preliminary debugger support. 

2 – Eclipse RustDT

RustDT is an Eclipse IDE for the Rust programming language.  It contains a base workspace and an extensible plug-in system for customizing the environment. It’s a free and open source and provides Rich Client Platform (RCP) for development of general purpose applications.

3 – Atom Editor

Developed by GitHub, the highly customizable environment and ease of installation of new packages has turned Atom into the IDE of choice for a lot of people. It is worth mentioning that the code examples provided in this dunebook were actually coded using Atom only. you can easily add Rust Programming language support using Rust Atom package.

4 – Sublime text 3

Sublime Text is a sophisticated text editor for code, markup, and prose. you’ll love the slick user interface, extraordinary features, and amazing performance. This is probably one of the most widespread code editors nowadays, some cool features of the sublime text. you can easily add Rust Programming language support to Sublime text using Rust Sublime text package.

5- Visual studio code

Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux, and macOS. It possesses basic features such as highlighting errors (and sometimes apply suggestions for fixing them), jump to definitions, show you the types of expressions, offer code completion, and more. It also includes advanced features such as support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring. Thus, it makes app development easier on any platform and has been supporting a range of major languages. Rust extension adds advanced language support for the Rust to Vs code.

6- Neovim

Neovim is a pretty cool version and successor of Vim IDE. It is one of the best IDE for Rust to work with. Apart from all the basic features provided by most of the other IDE’s, it contains several other powerful features such as key-bindings and modes, editing documents exactly where you intend to, complete customization and modularity with plugins. It also contains different plugins used to enhance or change the behavior of core vim and get better results; the most important ones are Nerdtree, Tagbar, FZF, Neo-complete etc.

7 – GEANY

Geany is a light weighted and modern in design GUI based text editor, that supports almost all major programming languages. It offers all the common features that you expect for any modern text editors, such as syntax highlighting, Auto-completion, Multiple document support, Simple project management, Syntax highlighting, Code folding (partially), Symbol lists, Code navigation and line numbering. As soon as you’ll open it up, you will find a lot of clean white space area to work in. 

8 – Spacemacs

Spacemacs in yet another text editor used for programming in Rust. It does provide the developers with all the basic features such as Auto-completion, Error detection, and correction, but apart from it, it has other major features such as community-driven configurations, Maintaining two completely separate keybinding systems and community maintained layers.It is an extensible and customizable text editor, which basically combines both Emacs and Vim editor, taking the best features of both of them and providing it together as one.Thus, you need to install Emacs first to operate Spacemacs.

Apparently, all these IDE’s possess their own advantages and the developer needs to see what he/she needs the most and should make choice accordingly. There are various other IDEs also that can be relied on for programming in RUST, apart from the mentioned ones, as per the user needs. All the best for your choices!

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Further reading about Rust Programming

The Rust Programming Language

Why you should move from Node.js to Rust in 2019

Rust Vs. Haskell: Which Language is Best for API Design?

7 reasons why you should learn Rust programming language in 2019

An introduction to Web Development with Rust for Node.js Developers

Learning Rust Programming


What's unique about Rust?

What's unique about Rust?

RustLatam 2019 - Niko Matsakis: What's unique about Rust?

Nicholas Matsakis is a Senior Staff Researcher at Mozilla Research and a member of the Rust core, compiler, and language design teams. He has been working on Rust since 2011 and did much of the initial work on its type system and other core features. He did his undergraduate study at MIT, graduating in 2001, and later obtained a PhD in 2011, working with Thomas Gross at ETH Zurich. He also spent several years at DataPower Technology, a startup since acquired by IBM, working on the JIT compiler and networking runtime.


Rust for IOT

Rust Programming Language - A language empowering everyone to build reliable and efficient software.

Is Rust ready for the embedded world yet?

If your IOT project is on ARM or MSP430, it already has native support in the Rust compiler, and AVR and RISC-V have compiler forks available. But architecture support is only the first challenge: If you're used to writing Rust for hosts that run an operating system, the paradigm shift of having to do everything yourself in the embedded world can be jarring. This talk will introduce the basic techniques for writing Rust to run microcontrollers, and survey outstanding embedded rust projects already available in the ecosystem.