Is there any way to construct a callable value in the stable version of Rust?

⚓ Rust    📅 2025-10-15    👤 surdeus    👁️ 1      

surdeus

Consider a certain API that is designed as follows:

pub fn update<F>(f:F) where F:FnOnce(i32){/* ... */}

Besides using closure to capture the environment variable, is there any way to construct a customized data structure that is callable in the stable version of Rust? Something like this:

struct Callable{
   data: Data,
}
update(Callable{data:Data{/* ... */}});

2 posts - 2 participants

Read full topic

🏷️ Rust_feed