From 53f2c3c1aa894141baa95bd2327e439c0b7ef90b Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Wed, 25 Sep 2024 15:18:08 +0200 Subject: [PATCH] [#394] Fix doc --- iceoryx2/src/sample_mut.rs | 4 ++-- iceoryx2/src/sample_mut_uninit.rs | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/iceoryx2/src/sample_mut.rs b/iceoryx2/src/sample_mut.rs index 3d64e85da..bf98af091 100644 --- a/iceoryx2/src/sample_mut.rs +++ b/iceoryx2/src/sample_mut.rs @@ -26,7 +26,7 @@ //! # let publisher = service.publisher_builder().create()?; //! //! // initializes the payload with `Default::default()` -//! let sample = publisher.loan()?; +//! let mut sample = publisher.loan()?; //! // override contents with 456 because its fun //! *sample.payload_mut() = 456; //! @@ -52,7 +52,7 @@ //! //! let slice_length = 12; //! // initializes every element of the slice with `Default::default()` -//! let sample = publisher.loan_slice(slice_length)?; +//! let mut sample = publisher.loan_slice(slice_length)?; //! // override the content of the first element with 42 //! sample.payload_mut()[0] = 42; //! diff --git a/iceoryx2/src/sample_mut_uninit.rs b/iceoryx2/src/sample_mut_uninit.rs index 536505671..e4d23950c 100644 --- a/iceoryx2/src/sample_mut_uninit.rs +++ b/iceoryx2/src/sample_mut_uninit.rs @@ -81,7 +81,7 @@ //! let slice_length = 4; //! let sample = publisher.loan_slice_uninit(slice_length)?; //! // initialize the slice with the numbers 1, 2, 3, 4 -//! let mut sample = sample.write_from_slice(vec![1, 2, 3, 4]); +//! let mut sample = sample.write_from_slice(&vec![1, 2, 3, 4]); //! //! println!("publisher port id: {:?}", sample.header().publisher_id()); //! sample.send()?; @@ -216,8 +216,9 @@ impl /// # .open_or_create()?; /// # let publisher = service.publisher_builder().create()?; /// - /// let sample = publisher.loan_uninit()?; - /// println!("Sample current payload {}", sample.payload()); + /// let mut sample = publisher.loan_uninit()?; + /// sample.payload_mut().write(123); + /// println!("Sample current payload {}", unsafe { sample.payload().assume_init_ref() }); /// /// # Ok(()) /// # } @@ -245,8 +246,8 @@ impl /// # .open_or_create()?; /// # let publisher = service.publisher_builder().create()?; /// - /// let mut sample = publisher.loan()?; - /// *sample.payload_mut() = 4567; + /// let mut sample = publisher.loan_uninit()?; + /// sample.payload_mut().write(4567); /// /// # Ok(()) /// # }