From 4082f373780cca126d397afff97d033fddae29d6 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Thu, 3 Feb 2022 13:17:34 +0100 Subject: [PATCH] Add no_std to the crate --- Cargo.toml | 2 +- src/lib.rs | 2 ++ src/test.rs | 9 ++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2602797..f6a7cda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ansi_colours" description = "true-colour ↔ ANSI terminal palette converter" -version = "1.1.0" +version = "1.1.1" readme = "README.md" authors = ["Michał Nazarewicz "] keywords = ["ansi", "terminal", "color", "rgb"] diff --git a/src/lib.rs b/src/lib.rs index 6d31858..68a4bfd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,6 +67,8 @@ //! } //! ``` +#![no_std] + pub(crate) mod ansi256; #[cfg(test)] mod test; diff --git a/src/test.rs b/src/test.rs index 072006f..5f80f99 100644 --- a/src/test.rs +++ b/src/test.rs @@ -107,10 +107,13 @@ fn test_to_ansi_approx() { /// purpose simply update the checksum in this test. #[test] fn from_rgb_checksum() { - let mut vec = Vec::with_capacity(1 << 24); + let mut buf = [0; 1 << 12]; + let mut checksum = 0; for rgb in 0..(1 << 24) { - vec.push(crate::ansi256_from_rgb(rgb)); + buf[rgb % buf.len()] = crate::ansi256_from_rgb(rgb as u32); + if rgb % buf.len() == buf.len() - 1 { + checksum = crc64::crc64(checksum, &buf); + } } - let checksum = crc64::crc64(0, vec.as_slice()); assert_eq!(3373856917329536106, checksum); }