#![cfg(feature = "compat")] #![cfg(not(target_os = "wasi"))] // WASI does not support all fs operations #![warn(rust_2018_idioms)]
use futures_io::SeekFrom; use futures_util::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt}; use tempfile::NamedTempFile; use tokio::fs::OpenOptions; use tokio_util::compat::TokioAsyncWriteCompatExt;
// Modify elements at position 2.
assert_eq!(file.seek(SeekFrom::Start(2)).await?, 2);
file.write_all(&[8, 9]).await?;
file.flush().await?;
// Verify we still have 8 elements.
assert_eq!(file.seek(SeekFrom::End(0)).await?, 8); // Seek back to the start of the file to read and verify contents.
file.seek(SeekFrom::Start(0)).await?;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.