#[derive(Debug, Clone, PartialEq)]
struct Point {
x: i32,
y: i32,
}
[workspace]
members = [
"server",
"client",
"common",
]
enum Status {
Ok,
Error(String),
Pending,
}
# Install
cargo install cargo-expand
# Expand entire crate
cargo expand
use std::collections::HashMap;
fn main() {
let mut scores = HashMap::new();
scores.insert("Alice", 10);
scores.insert("Bob", 20);
use std::fs;
use std::num::ParseIntError;
fn read_port(path: &str) -> Result<u16, Box<dyn std::error::Error>> {
let contents = fs::read_to_string(path)?;
let port: u16 = contents.trim().parse()?;
use std::fs;
use std::io::Result;
fn main() -> Result<()> {
let contents = fs::read_to_string("input.txt")?;
println!("File contents: {}", contents);
use std::fs::File;
use std::io::{BufRead, BufReader, Result};
fn main() -> Result<()> {
let file = File::open("input.txt")?;
let reader = BufReader::new(file);
fn greet(name: &str) {
println!("Hello, {}", name);
}
fn main() {
let owned = String::from("Alice");
use sqlx::PgPool;
use std::time::Duration;
use tokio::sync::mpsc;
#[derive(Debug, Clone)]
pub struct MetricPoint {
use std::fmt;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use uuid::Uuid;
pub struct Id<T> {
use std::time::Duration;
use rand::Rng;
#[derive(Clone, Debug)]
pub struct BackoffPolicy {
pub base_delay: Duration,