You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This release represents one of the largest additions to the Rust language and cargo in quite a while. With the stabilization of const generics, and the new feature resolver, along with more minor additions such as the `split-debuginfo` option, and the `addr_of!` API. Let's dive right into it!
27
+
This release represents one of the largest additions to the Rust language and Cargo in quite a while, stabilizing an MVP of const generics and a new feature resolver for Cargo. Let's dive right into it!
28
28
29
29
30
30
### Const Generics MVP
31
-
Before this release, Rust allowed you to haves your types be parameterized over lifetimes or types. For example if we wanted to have a `struct` that is generic over an array of 32 items, we'd write the following:
31
+
Before this release, Rust allowed you to haves your types be parameterized over lifetimes or types. For example if we wanted to have a `struct` that is generic over the element type of an array, we'd write the following:
32
32
33
33
```rust
34
34
structFixedArray<T> {
@@ -46,7 +46,7 @@ struct FixedArray<u8> {
46
46
}
47
47
```
48
48
49
-
This is a powerful feature that allows you to write reusable code with no runtime overhead. Enabling to have types that fit a wide variety of use-cases and types. However, until this release it hasn't been possible to easily be generic over the *values* of those types. This was most notable in arrays where they include their length in their type definition (`[T; N]`). Now with 1.51.0 you can write code that is generic over the values of any integer, `bool`, or `char` type! (Using `struct` or `enum` values is still unstable.)
49
+
This is a powerful feature that allows you to write reusable code with no runtime overhead. However, until this release it hasn't been possible to easily be generic over the *values* of those types. This was most notable in arrays which include their length in their type definition (`[T; N]`), which previously you could not be generic over. Now with 1.51.0 you can write code that is generic over the values of any integer, `bool`, or `char` type! (Using `struct` or `enum` values is still unstable.)
50
50
51
51
This change now lets us have our own array struct that's generic over its type *and* its length. Let's look at an example definition, and how it can be used.
While not often highlighted in the release, the Rust teams are constantly working on improving Rust's compile times, and this release marks one of the biggest improvements in a long time for Rust on macOS platforms. Debug information is code that maps the binary code back to your source code, so that the program can give you more information about what went wrong at run time. In macOS this is done with a tool called `dsymutil` which collects all the debug information into a single `.dSYM` folder.
132
+
While not often highlighted in the release, the Rust teams are constantly working on improving Rust's compile times, and this release marks one of the largest improvements in a long time for Rust on macOS platforms. Debug information is code that maps the binary code back to your source code, so that the program can give you more information about what went wrong at runtime. In macOS, debug info is typically collected using a tool called `dsymutil` which places all the debug information into a single `.dSYM` folder.
133
133
134
-
This tool provides a lot of benefits, however, one of the drawbacks has been that `dsymutil` is not really compatible with incremental recompilation. This means that even when you make a small change such as a function name, `dsymutil` will need to run over the entire final binary to produce the final `.dSYM` folder. This can sometimes add a lot to the build time, (especially for larger projects), but this has been a necessary step as without it Rust wouldn't be able to parse debug info on macOS.
134
+
This tool provides a lot of benefits, however, one of the drawbacks has been that `dsymutil` is not really compatible with incremental recompilation. This means that even when you make a small change such as a function name, `dsymutil` will need to run over the entire final binary to produce the final `.dSYM` folder. This can sometimes add a lot to the build time, especially for larger projects, as each dependency needs to be recollected, but this has been a necessary step as without it Rust wouldn't be able to load the debug info on macOS.
135
135
136
-
With the implementation of the Rust-based `backtrace` crate backend, we can now parse debuginfo even without running `dsymutil`. This can significantly speed up builds that include debuginfo and significantly reduce the amount of disk space used. We haven't run extensive benchmarks but have seen a lot of anecdata of people's builds building a lot faster on macOS with this behaviour.
136
+
Recently, Rust backtraces switched to using a different backend which supports loading debuginfo without needing to run `dsymutil`. This can significantly speed up builds that include debuginfo and significantly reduce the amount of disk space used. We haven't run extensive benchmarks but have seen a lot of reports of people's builds being a lot faster on macOS with this behavior.
137
137
138
138
You can enable this new behaviour by setting the `-Csplit-debuginfo=unpacked` flag when running `rustc`, or by setting the [`split-debuginfo`]`[profile]` option to `unpacked` in Cargo. The "unpacked" option instructs rustc to leave the .o object files in the build output directory instead of deleting them, and skips the step of running dsymutil. Rust's backtrace support is smart enough to know how to find these .o files. Tools such as lldb also know how to do this. This should work as long as you don't need to move the binary to a different location while retaining the debug information.
139
139
@@ -146,7 +146,7 @@ split-debuginfo = "unpacked"
146
146
147
147
### Stabilized APIs
148
148
149
-
In total, this release saw the stabilisation of 18 new methods for various types like `slice` and `Peekable`. One notable addition is the stabilisation of `ptr::addr_of!` and `ptr::addr_of_mut!`, which allow you to create unaligned references to data. Previously this wasn't possible because Rust requires `&/&mut` to be aligned and point to initialized data, and `&addr as *const _` would cause undefined behaviour as `&addr` needs to be aligned. These two macros now let you safely create unaligned references.
149
+
In total, this release saw the stabilisation of 18 new methods for various types like `slice` and `Peekable`. One notable addition is the stabilisation of `ptr::addr_of!` and `ptr::addr_of_mut!`, which allow you to create raw pointers to unaligned fields. Previously this wasn't possible because Rust requires `&/&mut` to be aligned and point to initialized data, and `&addr as *const _` would then cause undefined behaviour as `&addr` needs to be aligned. These two macros now let you safely create unaligned pointers.
150
150
151
151
```rust
152
152
usestd::ptr;
@@ -189,8 +189,8 @@ The following methods were stabilised.
0 commit comments