Skip to content

Instantly share code, notes, and snippets.

@SiegeLord
Created June 7, 2013 02:15
Show Gist options
  • Save SiegeLord/5726643 to your computer and use it in GitHub Desktop.
Save SiegeLord/5726643 to your computer and use it in GitHub Desktop.
struct Axes2D;
impl Axes2D
{
fn new() -> Axes2D
{
Axes2D
}
}
struct Axes3D;
impl Axes3D
{
fn new() -> Axes2D
{
Axes2D
}
}
enum AxesVariant
{
Axes2DType(Axes2D),
Axes3DType(Axes3D)
}
impl AxesVariant
{
fn command(self) -> &'static str
{
match self
{
Axes2DType(_) => "plot",
Axes3DType(_) => "splot",
}
}
}
struct Figure
{
priv axes: ~[AxesVariant]
}
impl Figure
{
fn new() -> Figure
{
Figure
{
axes: ~[]
}
}
fn axes2d<'l>(&'l mut self) -> &'l mut Axes2D
{
self.axes.push(Axes2DType(Axes2D::new()));
match self.axes[0]
{
Axes2DType(ref mut a) => a,
_ => fail!()
}
}
}
fn main()
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment