[][src]Macro slimweb::implgets

macro_rules! implgets {
    ($name:ident, ($($(#[cfg($cfg:ident = $val:tt)])? $op:ident),*)) => { ... };
    ($name:ident, $life:lifetime, ($($(#[cfg($cfg:ident = $val:tt)])? $op:ident),*)) => { ... };
}

Impl get_ref and get_mut.

There are only lifetime affected enums that this applies to currently.

Example:

This example is not tested
implgets!(Chunky, 'r, (Read, Write));

Becomes:

This example is not tested
impl<'r> Chunky<'r> {
	fn get_ref(&self) -> &Stream {
		match self {
			Chunky::Read(s) => s.get_ref(),
			Chunky::Write(s) => s.get_ref(),
		}
	}

	fn get_mut(&mut self) -> &mut Stream {
		match self {
			Chunky::Read(s) => s.get_mut(),
			Chunky::Write(s) => s.get_mut(),
		}
	}
}