O'Reilly logo

Mastering Rust by Vesa Kaihlavirta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summary

Rust is a safe language, which means that the compiler does a great job of protecting us from many simple and complex mistakes, such as memory access errors and accessing mutable values from several places. Sometimes the compiler is too strict, however, and we need to tell it to drop some of the protections.

This is especially needed when integrating with legacy ecosystems, such as C, which have no such safety settings. Therefore, any calls to the functions written in C are unsafe and must be tagged as such to satisfy the compiler. If we are careful, we can write safe wrappers around these unsafe blocks, which makes the C functions look like ordinary Rust functions. The Foreign Function Interface (FFI), like many other Rust things, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required