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:45 PM

New Paste 1 (Rust)

use std::marker::PhantomData;

pub struct RgbFormat;
pub struct RgbaFormat;

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

trait ComponentsCount {
    const COMPONENTS_COUNT: usize;
}

impl ComponentsCount for Image<RgbFormat> {
    const COMPONENTS_COUNT: usize = 3;
}

impl ComponentsCount for Image<RgbaFormat> {
    const COMPONENTS_COUNT: usize = 4;
}

trait Test {
    fn get_components_count() -> usize;
    // fn get_pixel(&self, x: usize, y: usize) -> &[u8; Self::COMPONENTS_COUNT];
    // fn set_pixel(&self, x: usize, y: usize, pixel: [u8; Self::COMPONENTS_COUNT]);
}

impl<T: ComponentsCount> Test for T {
    fn get_components_count() -> usize {
        Self::COMPONENTS_COUNT
    }
}