Skip to content

Commit

Permalink
[#394] Fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Sep 25, 2024
1 parent fcac17c commit 53f2c3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions iceoryx2/src/sample_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
//!
Expand All @@ -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;
//!
Expand Down
11 changes: 6 additions & 5 deletions iceoryx2/src/sample_mut_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down Expand Up @@ -216,8 +216,9 @@ impl<Service: crate::service::Service, Payload: Debug + ?Sized, UserHeader>
/// # .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(())
/// # }
Expand Down Expand Up @@ -245,8 +246,8 @@ impl<Service: crate::service::Service, Payload: Debug + ?Sized, UserHeader>
/// # .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(())
/// # }
Expand Down

0 comments on commit 53f2c3c

Please sign in to comment.