Skip to content

Commit

Permalink
Future-proof GRAY8 imports
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Aug 7, 2024
1 parent b744a92 commit f0fb5d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ Planned changes:
4. Don't enable `gbr` and `argb` features. All pixel types are enabled by default.
5. In generic code operating on pixels, add `Copy + 'static` bounds to the pixel types and/or their components.
6. Test your code with `rgb = { version = "0.8.46", features = ["unstable-experimental"] }`, which enables some of the future breaking changes on the older version. This feature flag is only for testing, and will be changed/removed in the future.
7. Avoid wildcard imports from `rgb::alt::*`, and avoid using `GRAY8`-`GRAYA16` type aliases.
5 changes: 5 additions & 0 deletions src/legacy/alt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ pub type ARGB16 = crate::Argb<u16>;
pub type GRB8 = crate::formats::grb::Grb<u8>;

/// 8-bit gray
#[deprecated(note = "Refer to ::rgb::alt::Gray<u8> directly (this type alias will change in the next major version)")]
pub type GRAY8 = Gray<u8>;

/// 16-bit gray in machine's native endian
#[deprecated(note = "Refer to ::rgb::alt::Gray<u16> directly (this type alias will change in the next major version)")]
pub type GRAY16 = Gray<u16>;

/// 8-bit gray with alpha in machine's native endian
#[deprecated(note = "Refer to ::rgb::alt::GrayAlpha<u8> directly (this type alias will change in the next major version)")]
pub type GRAYA8 = GrayAlpha<u8>;

/// 16-bit gray with alpha in machine's native endian
#[deprecated(note = "Refer to ::rgb::alt::GrayAlpha<u16> directly (this type alias will change in the next major version)")]
pub type GRAYA16 = GrayAlpha<u16>;


Expand Down Expand Up @@ -234,6 +238,7 @@ impl<T: Copy> From<Gray<T>> for GrayAlpha<T, u16> {
}

#[test]
#[allow(deprecated)]
fn gray() {
let rgb: crate::RGB<_> = Gray(1).into();
assert_eq!(rgb.r, 1);
Expand Down

0 comments on commit f0fb5d4

Please sign in to comment.