// Если делал так:
let cwd = std::env::current_dir().unwrap().parent().unwrap();
let my_path = &cwd.to_str().unwrap();
// и в дальнейшем, использовал my_path в своём коде так:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
...txt".to_string() + &my_path + "txt...
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// то выдавало ошибку:
// error[E0716]: temporary value dropped while borrowed
// creates a temporary value
// Если всё в одну строку - то работает:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
...txt".to_string() + &std::env::current_dir().unwrap().parent().unwrap().to_str().unwrap() + "txt...
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
let cwd = std::env::current_dir().unwrap().parent().unwrap();
error[E0599]: no method named `into_os_string` found for reference `&Path` in the current scope
|
88 | let my_path = cwd.into_os_string().into_string().unwrap();
| ^^^^^^^^^^^^^^ method not found in `&Path`
Arc нужно клонировать до move в замыкание, которое запускается на потоке. Если данные используются только на чтение, то этого будет достаточно, ...
#[derive(Debug)]
pub struct Data {
pub name: String,
pub dtime: chrono::DateTime<chrono::Local>,
pub id: i32,
pub n: u32,
}
//
let data = Data { name: "txt".to_string(), dtime: DateTime::parse_from_rfc3339("2023-07-10T10:20:30+03:00").unwrap().into(), id: 188, n: 5 };
можешь попробовать сделать функцию, которая будет возвращать значения переменных i и p
Но можно сделать так: macro_rules! f4 { ...