Skip to content

Instantly share code, notes, and snippets.

pub fn format_source_code(path: &~str){
let source_code = core::run::process_output("rustc", &[copy *path, ~"--pretty"]);
// if true then "--pretty" couldn't parse and we abort
if(source_code.output.is_empty()){
return;
}
let posix_path =
pub fn format_source_code(args: &[~str]) -> ValidUsage {
let mut args = args.to_owned();
// true if all specified files are formatable
fn check_for_error(args: &[~str]) -> bool {
for args.iter().advance |p| {
let source_code =
core::run::process_output("rustc", &[copy *p, ~"--pretty"]);
if (source_code.output.is_empty()) { return false; }
}
struct Node{
name: ~str,
child: Option<&'self Node>,
parent: Option<&'self Node>
}
struct Node{
name: ~str,
child: Option<Node>,
parent: Option<Node>
}
fn main(){
let n1 = Node {name: ~"n11",child: None, parent: None};
//#[allow(default_methods)]
struct Node<'self>{
name: ~str,
child: ~[Node<'self>],
parent: Option<&'self Node<'self>>
}
impl<'self>Node<'self> {
fn new(name: ~str )-> Node{
//#[allow(default_methods)]
struct Node<'self>{
name: ~str,
child: ~[Node<'self>],
parent: Option<&'self const Node<'self>>
}
impl<'self>Node<'self> {
fn new(name: ~str )-> Node{
//#[allow(default_methods)]
struct Node<'self>{
name: ~str,
child: ~[Node<'self>],
parent: Option<&'self const Node<'self>>
}
impl<'self>Node<'self> {
fn new(name: ~str )-> Node{
//#[allow(default_methods)]
struct Node<'self>{
name: ~str,
child: ~[Node<'self>],
parent: Option<&'self const Node<'self>>
}
impl<'self>Node<'self> {
fn new(name: ~str )-> Node{
struct Node<'self>{
name: ~str,
child: ~[Node<'self>],
parent: Option<&'self const Node<'self>>
}
impl<'self>Node<'self> {
fn new(name: ~str )-> Node{
Node {name: name,child: ~[], parent: None}
}
/home/maik/rustshader/scene.rs:13:2: 13:7 error: use of moved value: `self`
/home/maik/rustshader/scene.rs:13 self.child.push(node);
^~~~~
/home/maik/rustshader/scene.rs:12:23: 12:28 note: `self` moved here because it has type `&'self mut Node<'self>`, which is moved by default (use `copy` to override)
/home/maik/rustshader/scene.rs:12 node.set_parent(Some(self));
^~~~~
/home/maik/rustshader/scene.rs:27:0: 27:1 error: cannot borrow `n` as mutable more than once at a time
/home/maik/rustshader/scene.rs:27 n.add_child(n2);
^
/home/maik/rustshader/scene.rs:26:0: 26:1 note: second borrow of `n` as mutable occurs here