mirror of
https://github.com/dlang/phobos.git
synced 2025-04-26 05:00:35 +03:00
Fix std.mmap documentation
This commit is contained in:
parent
fc804bb8da
commit
94890e03dc
1 changed files with 5 additions and 3 deletions
|
@ -642,8 +642,9 @@ private:
|
|||
// This is typed as `void[]`, so cast to `char[]` or `ubyte[]` to use it
|
||||
const data = cast(const(char)[]) mmfile[];
|
||||
|
||||
// At this point, the file content hasn't been read yet.
|
||||
// The OS will
|
||||
// At this point, the file content may not have been read yet.
|
||||
// In that case, the following memory access will intentionally
|
||||
// trigger a page fault, causing the kernel to load the file contents
|
||||
assert(data[0 .. 5] == "hello");
|
||||
}
|
||||
|
||||
|
@ -656,8 +657,9 @@ private:
|
|||
scope mmfile = new MmFile(deleteme, MmFile.Mode.readWriteNew, 5, null);
|
||||
assert(mmfile.length == 5);
|
||||
|
||||
// Assign through operator overload of `MmFile`
|
||||
auto data = cast(ubyte[]) mmfile[];
|
||||
|
||||
// This write to memory will be reflected in the file contents
|
||||
data[] = '\n';
|
||||
|
||||
mmfile.flush();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue