Giter VIP home page Giter VIP logo

rust-incubator's Introduction

Rust Incubator

It wasn’t always so clear, but the Rust programming language is fundamentally about empowerment: no matter what kind of code you are writing now, Rust empowers you to reach farther, to program with confidence in a wider variety of domains than you did before.

Rust Book's Foreword

This project represents a hard-way step-by-step Rust learning course from language basics to a capability of web backend development.

Prerequisites

Toolchain

Bookshelf

Steps

Before you start

Create a new GitHub repository for yourself using this one as template.

NOTE: This learning course is constantly improving and evolving over time.

To be up-to-date with the recent changes in your own copy of this repository, attach the upstream history with the following commands:

git remote add upstream https://github.com/instrumentisto/rust-incubator.git
git fetch upstream main
git merge upstream/main --allow-unrelated-histories

And then, whenever you want to grab some new changes, do the following:

git fetch upstream main
git merge upstream/main

Additionally, to be aware about new changes, you may either watch this repository on GitHub, or even track it via RSS subscription.

Schedule

Each step must be performed as a separate PR (pull request) with an appropriate name and check-marked here in README's schedule after completion. Each step is a Cargo workspace member, so you can run/test it from the project root (i.e. cargo run -p step_1_8). Consider to use rustfmt and Clippy when you're writing Rust code.

More practice

rust-incubator's People

Contributors

0x07c0 avatar 50u10fca7 avatar andreyklumchyk avatar dependabot[bot] avatar evdokimovs avatar nyanpasu64 avatar tyranron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-incubator's Issues

Alternative solution for "Mutating embedded collection" without mem::replace

Background

While browsing through the repo, I found the Mutating embedded collection example. I realized that this isn't a fundamental limitation of &mut, but instead arises because a closure borrows the entire &mut self instead of the fields needed.

There has been some unresolved discussion on changing rustc to only borrow the fields actually used (Rust pattern: Precise closure capture clauses), but I don't know if it will be implemented anytime soon.

In the meantime, the code can be rewritten without mem::replace, but I don't know how to add it to the chapter.

use std::collections::HashSet;

struct Names {
    exclusions: Vec<String>,
    names: HashSet<String>,
}

impl Names {
    fn apply_exclusions(&mut self) {
        let names = &mut self.names;
        self.exclusions.drain(..).for_each(|name| {
            names.remove(&name);
        })
    }
}

Question

How should this solution be incorporated? Including both solutions is probably verbose, only including the current solution fails to teach a more optimal solution, and only including the no-replace solution defeats the purpose of the chapter.

Also I think it's worth mentioning std::mem::take (a convenient shorthand, but semi-recently added, in Rust 1.40 released 2019-12) as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.