Skip to main content

with_timeout

Function with_timeout 

Source
pub fn with_timeout<F, R>(
    timeout: Duration,
    test_fn: F,
) -> Result<R, TimeoutError>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,
Expand description

Run a test with a timeout

ยงExample

use windjammer_runtime::timeout::with_timeout;
use std::time::Duration;

let result = with_timeout(Duration::from_millis(100), || {
    // Test code that should complete quickly
    assert_eq!(1 + 1, 2);
});

assert!(result.is_ok());