Skip to content

Instantly share code, notes, and snippets.

@tanriol tanriol/ Secret

Created Apr 12, 2017
What would you like to do?
trait Handler {
fn handle(&mut self, &str) -> &str;
struct TestHandle {
uri: String,
value: Option<String>,
impl Handler for TestHandle {
fn handle(&mut self, s: &str) -> &str {
self.value = Some(format!("via {}", s));
struct A<S: Handler> {
name: String,
handler: S,
fn main() {
let mut handler = TestHandle {
uri: "/test".into(),
value: None,
let mut cont = A {
name: "runner".into(),
handler: handler,
println!("{}", cont.handler.handle("abc"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.