This month newsletter | learning resources

  • Source: Rust Daily
  • The author:RustDaily newspaper group
  • Post Editing: Su Yinrong (DaviRain)

Rust FAQ summary

The Rust TG Group “Rust Crowd” summarizes this list of Rust common questions.

Excerpts from this issue:

  1. How do I add asynchronous functions to traits?

Rust does not currently support adding asynchronous functions directly to traits, but you can use the async-trait library to do so. The library will bypass current language-level restrictions by rewriting asynchronous functions to return Pin

>, but with the added cost of heap allocation and dynamic distribution, it will not be added directly to Rust.

The reason asynchronous functions are not supported in attributes is that an asynchronous function is essentially a function that returns an IMPl Future, and Rust’s type system does not currently support the use of the Impl Trait on the return type of a Trait’s method. There are two approved RFCS that aim to address this issue: RFC 1598 generic association types and RFC 2071 IMPl traits exist types, but their compiler support is still being implemented.

  1. Why are Rust generated programs bulky? How can I minimize program volume?

Several factors contribute to Rust’s relatively large program size by default, including singleton, debug symbols, standard libraries, and so on. In general, Rust favors optimization over smaller volumes for performance.

Compiling in publish mode (–release) and (on Linux and macOS) using strips to remove symbolic information can reduce program size to some extent. Minimizing Rust Binary Size provides a fuller explanation of this problem.

Welcome to contribute:

Read more: rust-zh.github. IO/FAQ /

C++ to Rust – or how to render your mindset

The author intends to use Rust to re-implement the C++ tutorial <

>. This article is aimed at people who are interested in Rust or image rendering.

With this tutorial, you’ll end up with the preview below.

In the whole process, the author gives both C++ code and Rust code. For students familiar with C++, they can understand the difference between the two languages more clearly.

link

Rust-algorithms Write a textbook of algorithms with rust

The author @ebtech is born in applied mathematics, so the algorithms provided in this book mainly include applied mathematics (Fourier transform, etc.) algorithm and graph algorithm implemented by Rust.

warehouse

Review of asynchronous Rust

Parity engineer Tomaka’s blog post summarizes some of the key issues he encounters with Rust asynchronism in his daily development and is worth reading.

reading

Rust: Beware of escape sequences \n

Serde is the most popular Crate in Rust ecosystems, a LIZING data structure for efficiently serializing and deseri. It supports a variety of data formats including JSON, YAML, MessagePack, and more. Unlike many other (de) serializers, it does not use runtime reflection, but Rust’s compelling feature system. This makes Serde exceptionally efficient, because data structures essentially know how to SerializeorDeserialize themselves, and they do so by implementing the SerializeorDeserialize feature. Fortunately, this is thanks to most types, thanks to macro Derive. You may run into traps like I did, and in this blog post, the author wants to talk specifically about escape sequences.

ReadMore

Bevy – physics – fusion project

This project is the practice of the book Game Physics in a Weekend using the Rust programming language and the Bevy Game engine. This was a learning exercise for me to better understand how to implement the physics engine using Bevy and the math library GLAM. project

address

Rust optimization Techniques

If you want to write faster code in Rust, good news! Rust makes it easy to write fast code. The focus on zero-cost abstraction, the lack of implicit boxing, and static memory management mean that even naive code tends to be faster than equivalent code in other languages, and certainly faster than code in any equally secure language. But perhaps, like most programmers, you’ve spent your entire programming career without having to worry about any machine details, and now you want to dig a little deeper and find out the real reason for rewriting Python scripts. Rust runs 100 times faster and uses a tenth of the memory. After all, they all do the same thing and run on the same CPU, right?

So here’s an optimization guide for those who know how to program, but may not know how the code maps to real ones and zeros on the CPU. I’ll try to write practical tips on optimizing Rust code and explain why it’s faster than the alternatives, and we’ll end with a case study from the Rust standard library.

The original address

Write Pong on the operating system Rust gave me

We left off last time writing graphical drivers and event drivers for our operating system. We also added several system calls to handle the drawing primitives and handle keyboard and mouse input. Now we will use these animations to make a simple Pong game. Just as Hello World was a test of all programming languages, Pong was a test of all our graphics and event systems.

The article links

Rust Style Guidelines

Rust-guidelines collect emerging principles, conventions, abstractions, and best practices for writing RUST code.

Docs

GitHub

Avoid single-threaded memory access errors with Rust

In this article, we’ll look at several memory access errors in single-threaded C ++ and how Rust prevents us from making them. I wrote a short article showing memory access errors in C ++ and how Rust prevents us from accessing them. Directory: Returning References to temporariesShort lifetimesReferenes to Container contentsTricky Lifetime Extensions

Read the original

The Rust Web Developer Roadmap

Hyper-detailed roadmap for Rust Web developers.

github

The various policies that are returned referenced in Rust

This article summarizes several common ways to return references, which are highly recommended.

The original link

Learning Rust: Structs and Traits

This is the third part of a series of Rust videos, Structs and Traits. The content is relatively simple.

Tubing video

Tutorial: How to implement an iterator in Rust

In this tutorial you will learn how to implement iterators for a tree structure.

To read more

【 blog 】Rust namespace

An introduction to namespaces in Rust.

link

How have I used Rust to dramatically improve the performance of my note-taking software?

Giganotes is a note-taking software developed by the author. The author tries to use Rust to improve the performance of the software, and has achieved good results.

link

The Learn WGPU series has finally been fully upgraded to version 0.7!

Improvements have been made to the way wGPU creates render pipes. Most fields that are their own are grouped into structures, such as MultisampleState. This means simple pipes are easier to create because we can use Default::Default() or None for fields we don’t care about.

Read More 

Github 

How to make a shooter game with Rg3d!

How to create a shooter game in Rg3d is the second tutorial in the series.

Rg3d is a game engine written in Rust with OpenGl’s Rust binding: Glutin at the back end.

I have a simple question for the community: what stops you from using the engine? The lack of tutorials, immaturity, different approaches (no-ecs for example, or maybe you have your reason you want to share? I need to know what should be done first to make engine more newcomer-friendly. I have ~10 years of experience in gamedev and some things may be not obvious to me, so I need your help.

It was posted on Discord by the author of Rg3d on February 16. Since then, many people have expressed their thoughts, and the tutorial you’re seeing here is based on that survey. The Rust community itself is not very big, and the Rust gaming community is even smaller, but there are still a lot of people working on it. So if you’re interested in game development and you’re Rust’s kitchen, you haven’t tried developing games using Rust yet. Be sure to get a feel for developing games with Rust!

Read More

Rust asynchron is not a colored function!

This blog is Rust’s async isn’t f#@king colored!

This blog is derived from a famous blog in 2015: What Color is Your Function? In this blog, the function calls of programming languages are divided into different colors. In particular, it is pointed out that asynchronous calls and synchronous functions of multiple languages are two different colors, which will cause some pain to programmers when writing programs. The go, Java and other languages mentioned in the article do not belong to this kind of language, detailed can go to see the original text.

This blog explores whether Rust asynchronous programming has the same problem along the lines mentioned above. The conclusion is already betrayed by the title, Rust asynchronous is not a colored function!

Read More

Rust’s async isn’t f#@king colored!

I’ve seen the Toml file before

One writer posted on Reddit, “I Really Love TOML Files.

“I didn’t know about Toml files until I used Rust. Now I want to use it for everything.” This is the legend: brief encounter.

Why are Toml files loved? “They’re really cool for a lot of simple configurations! They don’t have the strangeness of YAML, they don’t have the stringiness of JSON, and they’re mostly flat, with almost no level indentation.”

Detailed link

Shooting games written in RG3D

Writing games in Rust: The Magic gun is in your hand.

This tutorial is the follow-up to a series of tutorials on making a 3D shooter using the RG3D game engine.

Detailed link

Rust and C speed comparison

Rust and C have very different programming styles, but they develop programs that run at roughly the same speed and memory usage. There is a big difference between what languages can achieve in theory and how they are used in practice. The authors summarize where Rust and C are respectively faster.

In a nutshell

  • Rust can optimize it in a low-level enough way if necessary to achieve the same performance as C;
  • Rust has higher levels of abstraction, convenient memory management, and rich third-party libraries;
  • The biggest potential of Rust is its ability to be fearless.

The article links

Why is Rust and Go better together?

Its simplicity, performance, and developer productivity make Go an ideal language for creating user-facing application services. Better control granularity makes Rust an ideal language for low-level operations. This doesn’t mean you have to choose one or the other, but rather the flexibility and performance of both when used together.

This article discusses the pros and cons of Rust and Go and how they complement each other.

The article links

Rust’s asynchrony is colored, but what’s the big deal

One area of controversy in language design is colored functions, which are divided into asynchronous and non-asynchronous functions. The term comes from a 2015 paper called “What Color Is Your Function? “, uses color as a metaphor for the often painful mismatch between synchronous and asynchronous functions in JavaScript and other languages with explicit asynchronous functions.

Rust’s async isn’t f#@king colored! .

Here the author will express his opinion through the original definition and practice: Rust has color.

The original link

Write a Postgres SQL printer with Rust: Part I

This is the first in a series of articles on the author’s PG-Pretty Project.

Authors can’t stand unformatted code, and for large projects, a uniform style can remove many barriers to understanding. But the author couldn’t find a good Postgres SQL-style printer, so he decided to write one himself.

The original link

Crust of Rust: The Drop Check

This is The latest episode of The Crust of Rust video series, “The Drop Check”.

Tubing video

Rust vs. Go: Why are they better together

Blog by Jonathan Turner and Steve Francia, while others may consider Rust and Go to be competitive programming languages, neither the Rust nor Go teams do. On the contrary, our team is very respectful of what others are doing and sees these languages as a tribute to our shared vision of the modern state of the entire software development industry.

Steve Francia [@spf13] is next door go community leader, see more

How do I use Rust to send email

Sending E-mail in Rust can be done in two ways: using an SMTP server or using a third-party service with an API, such as AWS SES or Sendgrid.

See the detailed implementation

Common vision for building Async Rust

Building a Shared Vision for Async Rust: Building a Shared Vision for Async Rust

The Rust Async Foundation working group believes Rust can be one of the most popular options for building distributed systems, from embedded devices to basic cloud services. No matter what they do with it, we hope all developers enjoy using Async-RUST. To do this, we need to move Async Rust out of its current “MVP” state and make it available to as many people as possible.

This article addresses

Magical use of Rust’s zero-size type (ZST)

There is a concept of zero-sized Types in Rust, ZST (zero-sized Types) for short. These types do not contain any information on their layout. But that doesn’t mean they aren’t important. This article will explain ZST design concepts and applications in depth. Interested partners can have a look.

The original link

Lens – rs directions

Zhihu contribution from Toe. The author previously implemented LENS using Rust, and this article focuses on how to play with the library len-RS.

The original link

Building OpenStreetMap Applications with Rust: Part VI

The latest chapter on Building An OpenStreetMap application with Rust concludes with a basic application that combines the previous chapters.

The original link

Use some tricks from Rust Iterator

The author summarizes a few tips related to Rust Iterator, and it feels good.

link

Pin and suffering

The latest article in the Cool Bear series gives you an in-depth look at Async in Rust.

The original link

Where to learn Rust in 2021

It’s 2021, where to learn Rust?

This article summarizes a series of Rust learning materials for those who want to learn from Rust.

The original link

Rusts Module System Explained

This paper introduces Rust module system in detail, from why the need for module system? To how to use very detailed, hope to module system in-depth grasp of the students can see.

The original link

LibP2p guide

This tutorial shows you how to build a very simple point-to-point application using Rust and the excellent Libp2p library.

reading

The sample code

Guide: Write an Entity Component System (ECS)

Learn what ECS is by writing a simple ECS system.

reading

Learn to fly: Using Rust/Neural Network/Genetic Algorithm to simulate evolution

  • Part I
  • Part II
  • Part III