Non-deterministic Lifetime Error
|
extern crate graphviz; |
|
|
|
use graphviz as dot; |
|
use std::str; |
|
|
|
type Nd = uint; |
|
type Ed = (uint, uint); |
|
struct Graph<'a> { |
|
nodes: Vec<&'a str>, |
|
edges: Vec<Ed>, |
|
} |
|
|
|
impl<'a> dot::Labeller<'a, Nd, Ed> for Graph<'a> { |
|
fn graph_id(&self) -> dot::Id<'a> { |
|
dot::Id::new("example3") |
|
} |
|
fn node_id(&self, n: &Nd) -> dot::Id { |
|
dot::Id::new(format!("N{:u}", *n)) |
|
} |
|
fn node_label<'a>(&'a self, i: &Nd) -> dot::LabelText<'a> { |
|
dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) |
|
} |
|
} |
|
extern crate graphviz; |
|
|
|
use graphviz as dot; |
|
use std::str; |
|
|
|
type Nd = uint; |
|
type Ed = (uint, uint); |
|
struct Graph<'a> { |
|
nodes: Vec<&'a str>, |
|
edges: Vec<Ed>, |
|
} |
|
|
|
impl<'a> dot::Labeller<'a, Nd, Ed> for Graph<'a> { |
|
fn graph_id(&self) -> dot::Id<'a> { |
|
dot::Id::new("example3") |
|
} |
|
fn node_id(&self, n: &Nd) -> dot::Id { |
|
dot::Id::new(format!("N{:u}", *n)) |
|
} |
|
fn node_label<'a>(&self, i: &Nd) -> dot::LabelText<'a> { |
|
dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) |
|
} |
|
} |
|
Sometimes I get this bad error message: |
|
lifetime-error.rs:21:34: 21:48 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements |
|
lifetime-error.rs:21 dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) |
|
^~~~~~~~~~~~~~ |
|
lifetime-error.rs:20:5: 22:6 note: consider using an explicit lifetime parameter as shown: fn node_label<'a>(&self, i: &Nd) -> dot::LabelText<'a> |
|
lifetime-error.rs:20 fn node_label<'a>(&self, i: &Nd) -> dot::LabelText<'a> { |
|
lifetime-error.rs:21 dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) |
|
lifetime-error.rs:22 } |
|
error: aborting due to previous error |
|
|
|
Other times I get this good error message: |
|
lifetime-error.rs:21:34: 21:48 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements |
|
lifetime-error.rs:21 dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) |
|
^~~~~~~~~~~~~~ |
|
lifetime-error.rs:20:5: 22:6 note: consider using an explicit lifetime parameter as shown: fn node_label<'a>(&'a self, i: &Nd) -> dot::LabelText<'a> |
|
lifetime-error.rs:20 fn node_label<'a>(&self, i: &Nd) -> dot::LabelText<'a> { |
|
lifetime-error.rs:21 dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) |
|
lifetime-error.rs:22 } |
|
error: aborting due to previous error |
This comment has been minimized.
tbu- commentedOct 2, 2014
I honestly do not see the difference between the good and the bad error message, and my local
difftool can't see it either. Are you maybe looking at different places?