This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mindTree:ofJenAI Mitch$ make | |
Compiling OF library for Release | |
make[2]: Nothing to be done for `ReleaseABI'. | |
Done! | |
Compiling ofJenAI for Release | |
find: demos: No such file or directory | |
find: demos: No such file or directory | |
Compiling src/main.cpp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mindTree:ofJenAI Mitch$ make | |
Compiling OF library for Release | |
make[2]: Nothing to be done for `ReleaseABI'. | |
Done! | |
Compiling ofJenAI for Release | |
find: demos: No such file or directory | |
find: demos: No such file or directory | |
find: demos: No such file or directory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//--------------- main.rs --------------------- | |
extern crate rand; // Why do I have to use this here, when I've already done so in a.rs? | |
mod a; | |
mod b; | |
fn main() { | |
a::test(); | |
b::test(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
I want a 'MyStruct' that can take any of the floating point primitive types. | |
When instantiating a 'MyStruct', I want to do so with MyStruct::new(val), | |
which should create a struct with val: val, but should also initialise | |
a: 0.0(f32/f64 - whatever it's floating point type is) and | |
b: 1.0(f32/f64 - whatever it's floating point type is). | |
Can I do this with a single impl method (like below)? Am I on the right | |
track, or is there a better way to handle this situation in Rust? (I'm | |
coming from c++). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use tempo::Tempo; | |
use time_signature::TimeSignature; | |
#[deriving(Clone)] // The error disappears if I remove this line. | |
#[deriving(Show)] | |
pub struct JTimePack<'r> { | |
sample_rate: int, | |
tempo: &'r Tempo, | |
time_sig: &'r TimeSignature, // << Error is found here pointing to 't' in 'time_sig' | |
ppqn: int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Is it considered bad practise to do something like this? | |
// Or is it fine? Common even? | |
// | |
// I'm specifically referring to impl'ing a trait method for a | |
// struct that returns a mutable reference to itself? In my | |
// current situation, it seems it will save a lot of unnecessary | |
// impl'ing when deriving from trait "A". | |
#[deriving(Show)] | |
pub struct MyStruct<'a> { i: int } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The example below gives the following: | |
// | |
// "error: cannot borrow `*self` as mutable more than once at a time" | |
// | |
// I understand why, but I am wondering if it is possible to define | |
// "setter" methods within the trait in a way similar to this? | |
#[deriving(Show)] | |
pub struct MyStruct<'a> { i: int, j: int } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// I'd like to be able to gain access to the 'foo', 'bar' and 'baz' members | |
// via the "get_my_struct" trait method. | |
// | |
// I'd like to be able to access both 'foo' and 'bar' as well as a mutable ref | |
// to 'baz' in order to write to 'baz' within the 'calc_baz' method. | |
// | |
struct A<'a> { | |
i: int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Firstly - I LOVE Rust! This is just something that has | |
// been cropping up more and more in my Rust coding experience | |
// recently, so I though it could be good to discuss it with | |
// fellow Rustaceans! | |
// | |
// TOPIC: | |
// I'd love the ability to be able to override parent trait | |
// methods with default methods in the child trait. | |
// | |
// The following is a pattern that I come across very often: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Color (..) | |
import Graphics.Collage (..) | |
import Graphics.Element (..) | |
import Keyboard | |
import Signal | |
import Time (..) | |
import Window | |
-- MODEL | |
mario = { x=0, y=0, vx=0, vy=0, dir="right" } |
OlderNewer