Skip to content

Instantly share code, notes, and snippets.

@simias
simias / fifo.rs
Last active August 29, 2015 14:13
use std::default::Default;
struct Fifo<T> {
buffer: [T; BUFFER_SIZE],
windex: Index,
rindex: Index,
}
impl<T: Default + Copy> Fifo<T> {
fn new() -> Fifo<T> {
src/main.rs:126:23: 126:86 error: mismatched types:
expected `*const libc::types::common::c95::c_void`,
found `*const libc::types::common::c95::c_void`
(expected enum `libc::types::common::c95::c_void`,
found a different enum `libc::types::common::c95::c_void`) [E0308]
@simias
simias / triangle.rs
Created February 9, 2015 21:30
Example program for gl-rs + rust-sdl2
// Copyright 2013 The gl-rs developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
int foo() {
return 0;
}
int bar(void) {
return 0;
}
int main() {
foo(42);
Compiling rustbook v0.3.0 (file:///home/simias/src/rustbook)
src/main.rs:13:1: 13:18 error: unstable feature
src/main.rs:13 #![feature(core)]
^~~~~~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
src/main.rs:14:1: 14:25 error: unstable feature
src/main.rs:14 #![feature(exit_status)]
^~~~~~~~~~~~~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
src/main.rs:15:1: 15:21 error: unstable feature
src/main.rs:22:31: 22:35 error: cannot borrow `*self` as mutable more than once at a time
src/main.rs:22 while let Some(msg) = self.next_packet() {
^~~~
src/main.rs:22:31: 22:35 note: previous borrow of `*self` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `*self` until the borrow ends
src/main.rs:22 while let Some(msg) = self.next_packet() {
^~~~
#![feature(no_std,core)]
#![no_std]
#![crate_type = "staticlib"]
#![feature(lang_items)]
extern crate core;
fn main() {
}
#![feature(lang_items)]
#![feature(no_std,core)]
#![no_std]
#![crate_type = "staticlib"]
extern crate core;
// Various lang items required by rustc
#[lang = "stack_exhausted"]
extern fn stack_exhausted() {}
OBJS = genplus-ntsc-md.o md_ntsc.o
NTSC_VARIANT = NTSC_COMPOSITE
CFLAGS = -fPIC -O2 -D$(NTSC_VARIANT)
all: genplus-ntsc.so genplus-ntsc.a
genplus-ntsc.so: $(OBJS)
$(CC) -shared -o $@ $(OBJS)
impl GdbRemote {
fn send_reply(&mut self, reply: Reply) -> Result<(), ()> {
match self.remote.write(&reply.into_packet()) {
//...
}
}
}
impl Reply {
pub fn into_packet(mut self) -> Vec<u8> {