From 582e154c4a9d8617677009dfaf20e29cecc22ac2 Mon Sep 17 00:00:00 2001 From: dswij Date: Tue, 23 Jan 2024 17:07:58 +0800 Subject: [PATCH] fix syntax on pin-init rust code example --- src/The-Safe-Pinned-Initialization-Problem.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/The-Safe-Pinned-Initialization-Problem.md b/src/The-Safe-Pinned-Initialization-Problem.md index 4e820e9..5e2e7d7 100644 --- a/src/The-Safe-Pinned-Initialization-Problem.md +++ b/src/The-Safe-Pinned-Initialization-Problem.md @@ -50,8 +50,8 @@ impl ListHead { /// # Safety /// /// Before using this [`ListHead`] the caller has to call [`ListHead::init`]. - unsafe fn new() -> ListHead { - ListHead { + unsafe fn new() -> Self { + Self { next: ptr::null_mut(), prev: ptr::null_mut(), } @@ -86,8 +86,8 @@ impl DoubleList { /// # Safety /// /// Before using this [`DoubleList`] the caller has to call [`DoubleList::init`]. - unsafe fn new() -> ListHead { - DoubleList { + unsafe fn new() -> Self { + Self { // SAFETY: We call `ListHead::init` in our own initializer. list_a: unsafe { ListHead::new() }, // SAFETY: We call `ListHead::init` in our own initializer.