Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Forked from anonymous/playground.rs
Created February 2, 2018 13:44
Show Gist options
  • Save stepankuzmin/e01b36285192b8d20215c7b39e67b0d2 to your computer and use it in GitHub Desktop.
Save stepankuzmin/e01b36285192b8d20215c7b39e67b0d2 to your computer and use it in GitHub Desktop.
use std::borrow::Cow;
struct A<'a> {
geometry_column: &'a str,
}
impl<'a> A<'a> {
fn geometry_column_mercator(&self, flag: bool) -> Cow<str> {
if flag {
self.geometry_column.into()
} else {
String::from("Hello world!").into()
}
}
}
fn main() {
let a = A {
geometry_column: "Foo",
};
println!("{:?}", a.geometry_column_mercator(true))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment