fn calculate_length(s: &String) -> usize {
s.len()
}
fn append_suffix(s: &mut String) {
s.push_str(" world");
use std::io::Write;
use tempfile::NamedTempFile;
fn main() -> std::io::Result<()> {
let mut tmpfile = NamedTempFile::new()?;
writeln!(tmpfile, "Hello, temp file!")?;
use std::collections::HashSet;
fn main() {
let mut words = HashSet::new();
words.insert("hello");
words.insert("world");
struct UserId(u32);
impl From<u32> for UserId {
fn from(id: u32) -> Self {
UserId(id)
}
use std::fmt;
struct Point {
x: i32,
y: i32,
}
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::thread;
fn main() {
let counter = Arc::new(AtomicUsize::new(0));
use std::marker::PhantomData;
struct Token<'a> {
_marker: PhantomData<&'a ()>,
}
use rayon::prelude::*;
fn main() {
let numbers: Vec<_> = (0..1000).collect();
let sum: i32 = numbers
use log::{info, warn, error};
fn main() {
env_logger::init();
info!("Application started");
fn divide(a: i32, b: i32) -> Option<i32> {
if b == 0 {
None
} else {
Some(a / b)
}
fn main() {
let numbers = vec![1, 2, 3, 4, 5];
let sum: i32 = numbers
.iter()
.filter(|&&x| x % 2 == 0)
trait Container {
type Item;
fn get(&self, index: usize) -> Option<&Self::Item>;
}
struct Warehouse {