kornelski / rust-rgb

struct RGB for sharing pixels between crates
https://lib.rs/rgb
MIT License
98 stars 19 forks source link

Struct naming and aliases for pixel types used in VFX? #62

Closed virtualritz closed 4 months ago

virtualritz commented 4 months ago

Naming of structs in this crate doesn't follow Rust naming conventions.

I.e. RGB should be Rgb, RGBA should be Rgba.

Type aliases should have the type prefix too. I.e. RGB8 should be RgbU8.

Finally, in visual effects, most image data is f16 or f32. It would be noice to have these as aliases.

The f16 ones would be behind a half feature gate that pulls in the resp. crate.

Available type aliases would then be:

kornelski commented 4 months ago

In your code you can rename these types with use … as or type, either at the root of your crate or a custom prelude module.

The channel type is generic, so you should be able to use it with f16 already.

Renaming types in this crate would be too disruptive for users, and I don't think it's worth the hassle. RGB is a much more common name used in the industry, which is bigger than Rust, and Rust's convention doesn't improve anything here.

virtualritz commented 4 months ago

I never understand the "hassle" argument for renames, something that takes a few seconds to do in a modern IDE, if you maintain a dependent crate.

And the versioning in Cargo.toml then makes sure the right rgb crate gets referenced.

I.e. if this was C/C++, fair enough. But in Rust this argument simply does not hold water.

Anyway, you are the maintainer. As the Brits would say: I hear you. :wink: