[workspace]
members = [
"server",
"client",
"common",
]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct CancelReason {
pub reason: String,
pub feedback: Option<String>,
use serde::Deserialize;
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Config {
pub server: ServerConfig,
enum Status {
Ok,
Error(String),
Pending,
}
use std::collections::HashMap;
use std::path::PathBuf;
use walkdir::WalkDir;
pub fn group_by_size(root: &str) -> HashMap<u64, Vec<PathBuf>> {
# 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 serde::Serialize;
use serde_json::Value;
#[derive(Debug, Clone, Serialize)]
#[serde(tag = "kind", rename_all = "lowercase")]
pub enum ChangeKind {
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");