protobuf 1.0.21

Rust implementation of Google protocol buffers
Documentation
use std::marker;
use std::ops;
use std::mem;

use core::ProtobufEnum;

struct ProtobufEnumVec<E : ProtobufEnum> {
    vec: Vec<i32>,
    phantom_data: marker::PhantomData<E>,
}

impl<E : ProtobufEnum> ProtobufEnumVec<E> {
    fn new() -> ProtobufEnumVec<E> {
        ProtobufEnumVec {
            vec: Vec::new(),
            phantom_data: marker::PhantomData,
        }
    }

    fn push(&mut self, e: E) {
        self.vec.push(e.value())
    }
}

impl<E : ProtobufEnum> ops::Index<ops::RangeFull> for ProtobufEnumVec<E> {
    type Output = ProtobufEnumSlice<E>;

    fn index(&self, index: ops::RangeFull) -> &ProtobufEnumSlice<E> {
        unsafe {
            mem::transmute(&self.vec[index])
        }
    }
}

struct ProtobufEnumSlice<E : ProtobufEnum> {
    phantom_data: marker::PhantomData<E>,
    slice: [i32],
}

impl<E : ProtobufEnum> ProtobufEnumSlice<E> {
    fn len(&self) -> usize {
        self.slice.len()
    }
}