Skip to content

Instantly share code, notes, and snippets.

Created February 2, 2018 13:44
Show Gist options
  • Save anonymous/e46525b630abd96c3a8101f9ab45e181 to your computer and use it in GitHub Desktop.
Save anonymous/e46525b630abd96c3a8101f9ab45e181 to your computer and use it in GitHub Desktop.
Rust code shared from the playground
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