forked from M-Labs/zynq-rs
1
0
Fork 0

libasync: change TcpStream::listen() callback constraint from Copy to Clone

This commit is contained in:
Astro 2020-04-14 00:08:57 +02:00
parent b26327e474
commit 60a29456ec
1 changed files with 2 additions and 1 deletions

View File

@ -82,10 +82,11 @@ impl TcpStream {
/// handshaking. Spawns additional tasks for each connection. /// handshaking. Spawns additional tasks for each connection.
pub fn listen<F, R, T>(port: u16, rx_bufsize: usize, tx_bufsize: usize, backlog: usize, f: F) pub fn listen<F, R, T>(port: u16, rx_bufsize: usize, tx_bufsize: usize, backlog: usize, f: F)
where where
F: Fn(Self) -> R + Copy + 'static, F: Fn(Self) -> R + Clone + 'static,
R: Future<Output = T> + 'static, R: Future<Output = T> + 'static,
{ {
for _ in 0..backlog { for _ in 0..backlog {
let f = f.clone();
task::spawn(async move { task::spawn(async move {
loop { loop {
// Wait for new connection // Wait for new connection