sornas / lingon

1 stars 0 forks source link

Make the AssetID fields public #44

Closed FredTheDino closed 3 years ago

FredTheDino commented 3 years ago

If you wanted to remove the wrapping type for some reason...

sornas commented 3 years ago

Do you need to create arbitrary asset IDs as well or do you only need to extract the inner value? I'd rather have this

impl std::ops::Deref for ImageAssetID {
    type Target = usize;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

in the second case.

sornas commented 3 years ago

If you need to create asset IDs as well I'd like this:

impl ImageAssetID {
    /// Wrap a usize as an ID.
    ///
    /// # Safety
    ///
    /// The usize needs to be a valid ID that has previously been returned from [AssetSystem::load_image].
    pub unsafe fn from_usize(u: usize) -> Self {
        Self(u)
    }
}

Otherwise we need to check all IDs in the asset code.

FredTheDino commented 3 years ago

My boilerplate alert is going off.

But yes, I need to create the ID's from usizes - unless I add another layer of indirection. I'm not super sold on the extra layer of indirection. We can diskus it further in person. There's a PR up for it https://github.com/FredTheDino/sylt-lang/pull/177

sornas commented 3 years ago

Superseded by #48