use std::sync::{Arc, Mutex};
use std::thread;
fn main() {
let data = Arc::new(Mutex::new(vec![1, 2, 3]));
use std::fmt::Display;
fn make_adder(x: i32) -> impl Fn(i32) -> i32 {
move |y| x + y
}
use std::ops::Deref;
struct MyBox<T>(T);
impl<T> Deref for MyBox<T> {
type Target = T;
struct UserId(u32);
impl From<u32> for UserId {
fn from(id: u32) -> Self {
UserId(id)
}
use std::fmt;
struct Point {
x: i32,
y: i32,
}
trait Container {
type Item;
fn get(&self, index: usize) -> Option<&Self::Item>;
}
struct Warehouse {
use std::fmt::Display;
fn print_it<T: Display>(value: T) {
println!("Value: {}", value);
}
use std::path::Path;
fn process_file(path: impl AsRef<Path>) {
let path = path.as_ref();
println!("Processing: {}", path.display());
}
#[derive(Default, Debug)]
struct Config {
host: String,
port: u16,
debug: bool,
}
#[derive(Debug, Clone, PartialEq)]
struct Point {
x: i32,
y: i32,
}
struct Logger {
name: String,
}
impl Drop for Logger {
fn drop(&mut self) {
fn print_size<T: ?Sized>(value: &T) {
// Can accept both &str and &String
println!("Value: {:p}", value as *const T as *const ());
}
fn main() {