RSSAmplifier

Blog

Guillaume Gomez's blog

IT/Rust-oriented blog posts

blog.guillaume-gomez.frRSS feed ↗50 posts

Latest posts

crates.io front-end and its accessiblity issue(s)

crates.io front-end and its accessiblity issue(s) Before we start, a disclaimer: this blog post is me venting out because I think crates.io could be much better than what it currently is. Of course, this is very subjective. And finally: this is not an invitation to go lash out or complain to the crates.io team. I told them everything that is listed here multiple times so no need to repeat it to…

sysinfo: Getting GPUs

sysinfo: Getting GPUs A while ago (5 years T_T), I wrote two blog posts (here and here) explaining how the Rust sysinfo crate retrieves information from systems. I recently added support to retrieve GPU information on Linux, macOS and Windows, and I think it's interesting to explain how it's done, so here we are (and also it took me 3 months to write this new feature so I'm definitely going to…

Rust GCC backend: Why and how

Rust GCC backend: Why and how Whenever you compile using Rust, the compiler goes through different passes and in the end, generated binary code for the target processor. By default, it uses LLVM as backend to generate the binary code, but more backends exist like cranelift and GCC. This post is about how it's possible for one compiler to use different backend to generate binaries, in particular…

New rust lint: function_casts_as_integer

New rust lint: function_casts_as_integer I recently added a new lint (emitting a warning by default) named function_casts_as_integer in the rust compiler when a function pointer is cast as a pointer in #141470. Let's dive into the reasons why it was added and what we plan to do next. Why? In rust, it's possible to do: Run let x = u32::max as usize; Which is fine... until you realize that u32::max…

Rust: Optimizing integer to string conversions

Rust: Optimizing integer to string conversions Doing integer to string conversions is very common when doing development (logging, or even showing frames per second (FPS) in video games...), not teaching you anything new here. As such, performance in this area is very important. Explanations of the initial situation If a type implements the Display trait, it also gets the ToString trait…

Rustdoc merged doctests (solved) issue on stable

Rustdoc merged doctests (solved) issue on stable The 1.85.1 Rust version just got released, and with it comes a fix for rustdoc merged doctests feature. You can take a look at the official blog post here. As a reminder, rustdoc is the Rust tool used to generate documentation. We recently added a new feature called "the merged doctests feature" which allows to greatly reduce the time needed to run…

Askama and Rinja merge

Askama and Rinja merge Some time ago, @djc offered @Kijewski and I to take over the maintenance of the askama crate as they don't have time to work on it anymore. We (@Kijewski and I) were originally reviewers and maintainers of the original askama project but had some disagreements over some specifics which we worked out in the meantime. You can find the list of changes between askama 0.12 and…

Doctests - How were they improved?

Doctests - How were they improved? rustdoc , the Rust documentation generator, just got a massive improvement which greatly reduces the time required for doctests in this pull request. This blog post will explain what are doctests, how they work and finally how we were able to improve them to this point. Doc... tests? You can write documentation in your source code with /// . This documentation…

docs.rs switching jinja template framework from tera to rinja

docs.rs switching jinja template framework from tera to rinja docs.rs is an important part of the Rust ecosystem as it provides documentation for all crates published on crates.io. Recently, we migrated the template engine we use to render web pages from tera to rinja in this pull request. This is a work that took us 10 months so I thought it could be interesting to talk about it. This blog post…

Writing your own Rust linter

Writing your own Rust linter Lints allow to improve codebases and even detect potential logic issues at compile-time. In rust, we have the incredible clippy which is a must use for any Rust project. However, because it is used everywhere, it also cannot cover all use cases. If you need to add new lints specific to your project(s), better write your own linter (to be used alongside clippy of…

Testing rustdoc

Testing rustdoc rustdoc is the Rust tool used to generate documentation based on your source code. Whenever you use cargo doc or browse documentation on docs.rs, the content you see was generated using the rustdoc tool. In this blog post, we will see how rustdoc is tested. It's actually into two main parts, the unit tests on one side and the test suites on the other. Unit tests Let's start by…

rustdoc and the re-exports

rustdoc and the re-exports rustdoc is the tool to generate documentation in rust. In this blog post we will see why handling re-exports with rustdoc is so complicated and how it's done. So first, let's see what a re-export is by taking an example. What are re-exports? Let's say we are writing a library (named lib ) with some types dispatched in sub-modules: Run pub mod sub_module1 { pub struct…

rustdoc: Recent UI and UX changes in generated documentation 2

rustdoc: Recent UI and UX changes in generated documentation 2 This blog post will talk about the recent UI/UX changes that happened in the rustdoc tool. As a reminder, rustdoc is the tool which generate the documentation for Rust source code. You can see previous UI/UX changes in this previous blog post. Now let's go through these changes! Simplifying system theme selection Until recently, the…

Rustdoc cleanups and improvements

Rustdoc cleanups and improvements We recently improved a lot of things in rustdoc. However, these changes are mostly invisible for users even though they're making their browsing experience better overall. I thought that it would be interesting to talk about these improvements and cleanups to see what impact they have. Reducing rustdoc generated documentation rustdoc generates a lot of HTML files…

rustdoc: Recent UI and UX changes in generated documentation

rustdoc: Recent UI and UX changes in generated documentation Rustdoc is the tool used to generate documentation of the Rust crates. It's also the tool used to generate documentation on docs.rs. Recently, we made a lot of UI (user interface) changes aiming to improve the UX (user experience) when browsing the documentation. All this was possible thanks to @jsha leading this effort. The goal of this…

sysinfo: version 0.22 and FreeBSD support

sysinfo: version 0.22 and FreeBSD support The sysinfo crate aims to provide systems' information. In this blog post, we will go through this (huge) sysinfo release and more particularly what I needed to do to add the FreeBSD support and what issues I encountered along the way. API changes A big change was the add of the possibility to specify what you want to refresh more specifically in the…

sysinfo: how to extract systems' information

sysinfo: how to extract systems' information The sysinfo crate aims to provide systems' information. This blog post will explain how it's done to allow you to get a better understanding on how things like CPU usage are computed. Please note that it will be mostly technical and is not specific to how sysinfo works but rather how it extracts systems' information. It doesn't cover all the information…

Improvements for #[doc] attributes in Rust

Improvements for #[doc] attributes in Rust Since Rust 1.54, we can now use function-like macros in attributes. It has a lot of advantages for the #[doc] attribute, let's check some of them! Using README file as crate documentation You can do it by simply writing at the top of your lib.rs file: Run #![doc = include_str!("README.md")] And that's it! Your README file will now be the crate…

Interacting with data from FFI in Rust

Interacting with data from FFI in Rust If you ever need to call a function from another language, you'll have to use FFI (Foreign Function Interface) and very likely handle pointers. To help you with that, here are some tips. Wrapping pointers using NonNull The NonNull type is very important: whenever interacting with pointers, it makes the nullability check automatic. In the following codes, we…

Performance improvement on front-end generated by rustdoc

Performance improvement on front-end generated by rustdoc We recently wrote a blog post about the performance improvement in rustdoc (the "back-end"). Now, it's time to talk about performance in the "front-end". As you will see, there is also a lot of things to say. Content size vs performance Since always, a big "fight" has been taking place in rustdoc between the page rendering speed and the…

doc(alias) is stable and it's gonna be super useful!

doc(alias) is stable and it's gonna be super useful! Since Rust 1.48, #[doc(alias = "...")] is now stable. Let's see what it might change and improve! What is it? As described in the Rust release blog post, you can add aliases on items. For example: Run #[doc(alias = "Foo")] pub struct Bar; So when you'll look for "Foo" in the documentation using the search input, Bar will show up. Nice add but…

New doc comment handling in rustdoc

New doc comment handling in rustdoc Today, I'll talk about a recently merged rustdoc pull request (you can see it here) which introduced two great changes: Unification of different doc comment item kinds. Removal of dark magic around indent handling. Unification of different doc comment kinds Some of you may have needed to make a part of a doc comment "optional" or depend on a given build setting.…

rgsl release 2.0: Huge cleanup and rewrite

rgsl release 2.0: Huge cleanup and rewrite The new rgsl version is now here! As a reminder, rgsl is a binding of the C GSL library (a mathematics library). It's been a work that took me months to finish but it's finally here! GSL versions supported The first big change of this new version is that I decided to drop the support of GSL < 2.0. It was just too hard to maintain two major versions at…

geos 7.0 release: More type safety, update dependencies and use std TryFrom

geos 7.0 release: More type safety, update dependencies and use std TryFrom The new geos version is now here! As a reminder, geos is a binding of the C++ geos library which provides tools to perform geospatial operations. I'm very proud of this release for a few reasons that I'll now describe. More type safety Thanks to a contributor, we realized that the FFI bindings were not always perfectly…

doc-comment 0.4: proc-macro time

doc-comment 0.4: proc-macro time Before starting, here is a small reminder: the doc-comment crate provides macros to help you write and test documentation. Until now, the crate was using declarative Rust macros. However, even though I appreciated its simplicity a lot, it had some clear limitations that couldn't be overcome. For example, you couldn't use the doc_comment! macro to document the…

New process-viewer release: processes disk usage

New process-viewer release: processes disk usage The new process-viewer version is here! It follows the sysinfo release which added processes' disk I/O usage information (you can read the blog post about this release here). Disk usage The processes tab now has a new column "disk I/O usage": The process dialog also got a new graph: As well as new fields: Very convenient if you want to check which…

New sysinfo release: processes disk usage

New sysinfo release: processes disk usage The new sysinfo version is here! As a reminder, sysinfo is a crate which provides system information. Let's check what's new! Disk usage As you may have guess from the title, this release brings the processes' disk usage. Example: Run use sysinfo::{ProcessExt, System, SystemExt}; let mut s = System::new(); s.refresh_processes(); for (pid, process) in…

New process-viewer release

New process-viewer release Following both the new sysinfo release and the new gtk-rs release, I worked on updating process-viewer as well. So here comes the 0.3.3 version! As a reminder, process-viewer is a process viewer GUI written in Rust. Let's check what's new! Network interfaces In the last sysinfo release, I worked mostly on bringing more information and control over the networks. Systems…

Guide on how to write documentation for a Rust crate

Guide on how to write documentation for a Rust crate I have received (a lot of) requests about writing a guide on how to write documentation in Rust lately. I'm quite happy that people finally gets interested into this area so let's not let it rest and let's go! Basics Before explaining how to write nice documentation and everything, we need to cover the basics on how to actually write…

cfg(doctest) is stable and you should use it

cfg(doctest) is stable and you should use it I arrive a bit late considering that #[cfg(doctest)] is stable since rust 1.40 but I think it's important for people to know about this feature and how to use it. What is it? First things first, what is this feature about and when is it set? The answer: when running rustdoc --test (or cargo test on the doc subpart). Why use it? Now, why you should care…

New sysinfo release: time to extend APIs

New sysinfo release: time to extend APIs Little reminder first: sysinfo is crate to get system information, such as processes, processors, disks, components and networks. Now let's go! :) Time for a new sysinfo release! In this version, multiple things were added, such as the load average and processor information (frequency and vendor ID). The API has also been reworked to give you more control.…

New sysinfo release (OSX performance improvements)

New sysinfo release (OSX performance improvements) Hi everyone! Today, sysinfo has received a new update with nice performance improvements on OSX. As a reminder, sysinfo is crate used to get systems' information (Linux, Windows, OSX, Android and raspberry pi are supported). This release is the last one in the performance improvements series (you can read the previous blog posts here and here) .…

New sysinfo release

New sysinfo release Hi everyone! Today, sysinfo has received a new update with nice improvements. As a reminder, sysinfo is crate used to get systems' information (Linux, Windows, OSX and raspberry pi are supported). Let's take a look: More specific refresh methods Some people complained that they didn't have enough control over what they were refreshing system (aka CPU, memory and components'…

Rust 2020: what about feedbacks?

Rust 2020: what about feedbacks? The Rust teams made a call for people to write blog posts about Rust 2020, so here's mine! I've been working on the Rust compiler for years. It got stabilized, then matured through the years. From my point of view, it now has most of the features I wanted. So what would I want for Rust 2020 and what's coming after? To sum it up: feedbacks. It might sound little but…

GNOME+Rust Hackfest #6 in Roma

GNOME+Rust Hackfest #6 in Roma End of the year, meaning it's time for a new GNOME+Rust hackfest and its feedback! GNOME+Rust hackfest? The goal of these hackfests is to improve the interactions between Rust and the GNOME libraries. This sixth edition happened in Rome. What have we done? This time, we focused on two things: polishing and cleaning up. If you haven't guess at this point, a new gtk-rs…

New NodeJS framework to improve rustdoc UI tests

New NodeJS framework to improve rustdoc UI tests Hi everyone! Today, I'd like to introduce to you a new NodeJS framework called browser-ui-test. You can find it on github and on npmjs. Its default behaviour is to compare screenshots after a list of actions and compare them to detect regressions. But it's much more than that! Before presenting the framework, let's talk about what it has to do with…

GNOME+Rust Hackfest #5 in Berlin

GNOME+Rust Hackfest #5 in Berlin Last week was the fifth edition of the GNOME+Rust hackfest. What about talking a bit about what happened there? What have we done? The goals of this edition were: Provide a gir tutorial so that people could generate their own GObject-based library. Generate builder for widgets (@antoyo wrote a blog post about it available here). Improve cairo crate API. Upgrade all…

New geos release

New geos release The 5.0 version of the geos crate, the binding of the Geometry Engine Open Source C library was just released! The last version came out not so long ago, however it lacked quite a number of things, starting with functions available in the C library. This new release changes everything. Time to write about what happened in this new version! A quick note before starting: when "geos"…

Keeping Rust projects' README.md code examples up-to-date

Keeping Rust projects' README.md code examples up-to-date Because keeping documentation up-to-date is very important (and should be a must have!), we need to check if the examples are still valid after every new updates. Luckily, rustdoc already makes such things very easy: /// This a nice example: /// /// ``` /// let x = 2; /// assert!(x & 1 == 0); /// ``` /// pub fn foo() {} When you run cargo…

GNOME+Rust Hackfest in Thessaloniki

GNOME+Rust Hackfest in Thessaloniki The last GNOME+Rust hackfest just ended, time for a blog post to sum up what happened in this event! What happened? Just like usual, a lot of things. This time, we discussed more than usual, mainly about how things should move in gtk-rs future, things to be improved based on users' feedbacks and where Rust could be used in GNOME more generally. Some interesting…

Rust+GNOME Hackfest in Madrid

Rust+GNOME Hackfest in Madrid Last week was the third edition of the Rust+GNOME hackfest. What about talking a bit about what we achieved? What have we achieved? The goals of this edition were: Improve gnome-class. Improve gtk-rs continuous integration process. Improve gtk-rs crates bindings. And I'm happy to say that we were able to achieve all of these goals! Let's go more into the details now.…

New sysinfo version (huge performance improvements!)

New sysinfo version (huge performance improvements!) Hi everyone! It's (very) rare that I make a post about a new sysinfo version but I think this one is definitely worth it! Some what about those performance improvements? Like the title states, this new version comes with great performance improvements. We're talking about 3x faster on macos, 2x faster on linux and 3x faster on windows (the…

Using macro to generate generic docs?

Using macro to generate generic docs? We were recently able to finally make the docs for integer primitive types much more accurate (thanks to @antoyo!). Now, the code examples match the type for which they're written. No more i32 examples for i128 (I think you got the idea at this point)! Now, I think a few people might be interested by the method we used to achieve such a result so let's talk…

Rust+GNOME Hackfest in Berlin

Rust+GNOME Hackfest in Berlin Last weekend was the second Rust+GNOME hackfest. Just like the first time, it aimed to bring more Rust into GNOME libraries and more GNOME libraries into Rust. This time, it took place in Berlin at the [Kinvolk office]. What happened in there? A lot of things as you imagine! Allowing developers to work together in a same place fastened up things a lot! Let's make a…

New rustdoc rendering common errors

New rustdoc rendering common errors Since a few weeks, it's possible to use pulldown instead of hoedown in order the render the markdown from the documentation comments with the following command: rustdoc -Z unstable-options --enable-commonmark You can take a look at the tracking issue here. This switch is really important for Rust for a few reasons: hoedown isn't maintained anymore hoedown is…

Gtk-rs release process

Gtk-rs release process Given the growing complexity of gtk-rs release and the upcoming number of related questions to this topic, I thought it might be interesting to have a little post on how it worked and how it now works. I talk a bit as well of the reasons of why gtk-rs isn't a single repository. In the old times Like I said just above, I changed very recently how we release a new version of…

Little tour of multiple iterators implementation in Rust

Little tour of multiple iterators implementation in Rust A common issue for Rust newcomers seems to be to actually implement an Iterator . So I decided to write this small blog post in order to look at the basics. So first, as far as I can tell, there are two types of Iterator : Iterators over a type. Generators. Iterators over a type An iterator over a type is simply an iterator which will…

Rust asynchronous HTTP server with tokio and hyper

Rust asynchronous HTTP server with tokio and hyper In the two last weeks, I worked on a project: writing a small REST API server in Rust. The goal was to compare the performance between this one and the one wrote in C. To do so, we decided to use tokio and hyper. The C server has been written with a different design: threading and epolling. Asynchronous and Rust Recently, hyper switched to tokio…

Generating doc with rustdoc and a custom theme

Generating doc with rustdoc and a custom theme Only a few people know, but it's actually possible (at least only on nightly) to generate doc with another color theme has been possible for a few months now. I personally prefer dark ones so in here I'll use this CSS file: /** * Copyright 2016 Guillaume Gomez */ body { background-color: #353535; color: #BABABA; } h1, h2,…

Rust merge process

Rust merge process New contributors on the Rust project are generally a bit lost on how the merge process is working. This little article intends to make things a bit more clear. But first, let's start with steps before opening a Pull Request. Things to do before asking a review First, it might seem obvious but better sure than sorry: run tests! The command is as follow: make check It can takes…