Rust lingo ~= a C++ trivial type/Java POD?

A Rust struct that is eligible to have the Copy trait would be called in C++ a trivial type. (I think) Java folks would call it a POD.

Is there Rust lingo for the same?

I've mainly heard them referred to as Copy types, but I think most programmers would understand you when you call something a POD type.

+1 Copy type.
Take into account the compiler can still reorder the items in a composite structure if it sees fit. (Unless representation changed explicitly.)

2 Likes

FTR, Java has nothing that's really comparable to a Copy type, as anything more complex than the builtins are objects, and those are heap-allocated, whereas Copy types by definition fully live on the stack.

As for something akin to POJOs (Plain Old Java Objects), which I understand to be types that are nothing more than simple containers (i.e. they may have getters and setters, but no complex behavior), I've been calling the Rust analogue POROs.
One difference between POJOs and POROs though is that in Rust I just can't get myself to make PORO fields private, so they tend to be the only types I define that have public fields and no methods.

One of these days Java will have value types implemented/available, and they’ll be copy types.

FWIW, I also refer to these rust types as simply “copy types”.

Thing is, a PORO isn't necessarily a Copy type. Consider this code:

struct Output {
    input: String,
    byte_size: usize,
    // perhaps other fields here
}

This is an example of a non-Copy PORO because String itself is not Copy.

To be plain the type must not have a Drop at least. Vec drops, hence String and Output drop. You seem to be describing types made up of just std, although probably with more restriction.

I've personally taken to calling anything that doesn't need an explicit Drop (because it's made of std types) as "POROus" (because things pass through it freely and I'm funny like that; the "us" is "user struct" for what it's worth), and anything that needs explicit dropping (impl Drop) to behave as I'd expect it/like it to as a "Rust bucket".

Probably not overly helpful as the phrase "Rust bucket" implies something more to many people, but why limit ourselves to the legacy of other languages?

Thanks for the thoughtful replies everyone! My goal is really a phrase that most people would understand what I meant if I used it without explanation. "copy type" (or maybe "copyable type") seems like pretty good short hand for a "type that implements the Copy trait".

Thanks!