-
-
Save indykish/3ca088eea2e55bcb63da2c27af6a801b to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused)] | |
trait Foo { | |
fn bar(&self); | |
fn baz(&self); | |
} | |
struct MyStruct; | |
impl Foo for MyStruct { | |
fn bar(&self) { | |
let mut d = vec!["a", "b", "c", "d","e","f","g","h", "i", "l", "m"]; | |
d.sort_by(|a, b| a.partial_cmp(b).unwrap()); | |
let mut s = vec!["c", "b", "a"]; | |
s.sort_by(|a, b| a.partial_cmp(b).unwrap()); | |
let u = d.clone().into_iter() | |
.map(|x| s.binary_search(&x).and_then(|i| d.get(i).ok_or(0))).map(|y|y.unwrap_or(&" ")).collect::<Vec<_>>(); | |
println!("==> {:#?}", u); | |
} | |
fn baz(&self) { | |
// let's not worry about implementing baz() for now | |
todo!(); | |
} | |
} | |
fn main() { | |
let s = MyStruct; | |
s.bar(); | |
// we aren't even using baz() yet, so this is fine. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment