src/bisection_tree/supportid.rs

Tue, 06 Dec 2022 08:32:57 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Tue, 06 Dec 2022 08:32:57 +0200
changeset 15
e03ce15643da
parent 5
59dc4c5883f4
permissions
-rw-r--r--

Fix broken links in doc comments after Mapping -> Apply change.

use std::marker::PhantomData;

/// Standard identifier for a [`Support`][super::support::Support] stored in a
/// [`BTImpl`][super::bt::BTImpl] as [`BTImpl::Data`][super::bt::BTImpl::Data].
#[derive(Debug)]
pub struct SupportId<S> {
    pub id : usize,
    _phantom : PhantomData<S>
}

// derive fails so need to do Copy and Clone manually

impl<S> Clone for SupportId<S> {
    fn clone(&self) -> Self {
        SupportId { id : self.id, _phantom : PhantomData }
    }
}

impl<S> Copy for SupportId<S> {}

impl<S> From<u32> for SupportId<S> {
    #[inline]
    fn from(id : u32) -> SupportId<S> {
        SupportId { id : id as usize, _phantom : PhantomData }
    }
}

impl<S> From<usize> for SupportId<S> {
    #[inline]
    fn from(id : usize) -> SupportId<S> {
        SupportId { id : id, _phantom : PhantomData }
    }
}

impl<S> Into<usize> for SupportId<S> {
    #[inline]
    fn into(self) -> usize {
        self.id
    }
}

mercurial