What do you call static methods in Rust?

⚓ rust    📅 2025-05-20    👤 surdeus    👁️ 3      

surdeus

Warning

This post was published 40 days ago. The information described in this article may have changed.

Technically, an "associated function" is one that's associated with a type; and a "method" is an associated function that takes a self parameter.

What do you call the kind of associated function that doesn't have a self parameter?

I'm working on revisions to the book Programming Rust and trying to decide if we should make a change. In the current edition we use the made-up term "type-associated function":

An impl block for a given type can also define functions that don't take self as an argument at all. These are still associated functions, since they're in an impl block, but they're not methods, since they don't take a self argument. To distinguish them from methods, we call them type-associated functions.

Using a made-up term is pretty terrible, but "static method" is wrong in two ways (it's neither a static nor a method; discuss) and everything else seems worse ("constructor", "non-method associated function", ...?).

So: What do you call these things in everyday conversation? Maybe we should go with that.

3 posts - 3 participants

Read full topic

🏷️ rust_feed