gear idea
Possible Rust

Learning what’s possible in Rust.
Jump to Navigation

CategoryGuides


What Can Coerce, and Where, in Rust

Rust supports a number of type coercions, which implicitly convert one type to another. As in any language with coercion, there is a trade-off made between clarity when reading and ease of writing. While disagreement may be had about whether Rust’s list of supported coercions is best, there is value in learning the coercions available, as some are central to functioning or idiomatic Rust code. In this post, I describe what coercions are possible, and where they can happen.

Jul 6th, 2021 · Guide · #types · By Andrew Lilley Brinker

How to Read Rust Functions, Part 1

Rust functions are surprisingly diverse, sitting at the intersection of multiple language features which may take time to understand. In this post, we’ll walk through those features and explain how they appear in function signatures, so you can be well-equipped to understand functions you see in the wild, or identify the best way to write the functions you need in your own code.

Jan 26th, 2021 · Guide · #functions · By Andrew Lilley Brinker

Inbound & Outbound FFI

Foreign Function Interfaces (FFI) are a core mechanism for enabling integration of new languages into existing codebases or building on existing libraries. That said, the term “FFI” is often overloaded in ways that may be unclear or ambiguous, and the area can seem overwhelming to approach. In this post, I explain the two “directions” of FFI, some patterns for how FFI in each direction is handled in Rust and further break down some FFI design approaches.

Aug 5th, 2020 · Guide · #ffi · By Andrew Lilley Brinker

Enum or Trait Object

Rust has two major mechanisms for delegating logic: enums and trait objects, and it may be unclear when to use one or the other. In this post, I will walk through how each works, what the tradeoffs are, and how to choose the right option for your code.

Jul 27th, 2020 · Guide · #enums, #trait objects · By Andrew Lilley Brinker