Surprise! We've been running on hardware provided by BuyVM for a few months and wanted to show them a little appreciation.
Running a paste site comes with unique challenges, ones that aren't always obvious and hard to control. As such, BuyVM offered us a home where we could worry less about the hosting side of things and focus on maintaining a clean and useful service! Go check them out and show them some love!
Submitted on March 10, 2023 at 11:23 PM

New Paste 1 (Rust)

use std::marker::PhantomData;

pub struct RgbFormat;

impl RgbFormat {
    const COMPONENTS_COUNT: usize = 3;
}

pub struct RgbaFormat;

impl RgbaFormat {
    const COMPONENTS_COUNT: usize = 4;
}

pub struct Image<Format = RgbFormat> {
    pub data: Vec<u8>,
    pub width: usize,
    pub height: usize,
    format: PhantomData<Format>,
}

macro_rules! image_with_format {
    ($format:ident) => {
        impl Image<$format> {
            pub fn get_pixel(&self, x: usize, y: usize) -> &[u8; $format::COMPONENTS_COUNT] {
                todo!()
            }

            pub fn set_pixel(&self, x: usize, y: usize, pixel: [u8; $format::COMPONENTS_COUNT]) {
                todo!()
            }
        }
    }
}

image_with_format!{RgbFormat}
image_with_format!{RgbaFormat}