pub struct Point<T>{
pub x: T,
pub y: T,
}
impl<T> Point<T>{
pub fn new(value1: T, value2: T) -> Point<T>{
Point{
x: value1,
y: value2,
}
}
pub fn x(&self) -> &T{
&self.x
}
pub fn y(&self) -> &T{
&self.y
}
}
impl<T> Point<&T>{
pub fn old(&self, value: &T){
panic!("aaaaaaaaaaaaa");
}
}
pub fn str_cmp(){
let string1 = String::from("abcd");
let string2 = "xyz";
let result = longest(string1.as_str(), string2);
println!("the longest string is {}", result)
}
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str{
if x.len() > y.len(){
x
}else{
y
}
}
pub fn novel_sentence(){
let novel = String::from("ffffffffffffffffffffffffff.fffffffffffffffffffffff");
let first_sentence = novel.split('.').next().expect("no .");
}
struct ImportantExcept<'a>{
part: &'a str,
}
impl<'a> ImportantExcept<'a>{
fn announce_and_return_part(&self, announcement: &str) -> &str{
self.part
}
}