// build.rs
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let version = env!("CARGO_PKG_VERSION");
println!("cargo:rustc-env=BUILD_VERSION={}", version);
use std::io::Write;
use tempfile::NamedTempFile;
fn main() -> std::io::Result<()> {
let mut tmpfile = NamedTempFile::new()?;
writeln!(tmpfile, "Hello, temp file!")?;
use std::process::Command;
fn main() -> std::io::Result<()> {
let output = Command::new("ls")
.arg("-la")
.output()?;
use std::path::Path;
fn process_file(path: impl AsRef<Path>) {
let path = path.as_ref();
println!("Processing: {}", path.display());
}
use std::ops::Deref;
struct MyBox<T>(T);
impl<T> Deref for MyBox<T> {
type Target = T;
trait Container {
type Item;
fn get(&self, index: usize) -> Option<&Self::Item>;
}
struct Warehouse {
use std::fmt::Display;
fn make_adder(x: i32) -> impl Fn(i32) -> i32 {
move |y| x + y
}
const MAX_SIZE: usize = 1024;
const fn square(n: u32) -> u32 {
n * n
}
fn print_size<T: ?Sized>(value: &T) {
// Can accept both &str and &String
println!("Value: {:p}", value as *const T as *const ());
}
fn main() {
use color_eyre::Result;
fn might_fail() -> Result<()> {
Err(color_eyre::eyre::eyre!("Something went wrong"))
}
use nom::{
bytes::complete::tag,
character::complete::digit1,
IResult,
};
use parking_lot::Mutex;
use std::sync::Arc;
use std::thread;
fn main() {
let counter = Arc::new(Mutex::new(0));