struct Locked;
struct Unlocked;
struct Door<State> {
_state: std::marker::PhantomData<State>,
}
use tokio::time::{sleep, Duration};
async fn fetch_data() -> String {
sleep(Duration::from_millis(100)).await;
"data".to_string()
}
// In a proc-macro crate:
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput};
#[proc_macro_derive(MyTrait)]
#![feature(asm)]
fn add_asm(a: u64, b: u64) -> u64 {
let result: u64;
unsafe {
asm!(
fn print_size<T: ?Sized>(value: &T) {
// Can accept both &str and &String
println!("Value: {:p}", value as *const T as *const ());
}
fn main() {
mod utils {
pub fn helper() {
println!("Helper function");
}
fn private_fn() {}