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.
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.
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.
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.