From a6ff214603c079fa3bdfb2477a4dafcf5f66840d Mon Sep 17 00:00:00 2001 From: Carl Fredrik Samson Date: Sat, 25 Jan 2020 17:45:15 +0100 Subject: [PATCH] update --- ...mation.md => 0_1_background_information.md} | 18 ++++++++++++++++++ src/SUMMARY.md | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) rename src/{0_1_BackgroundInformation.md => 0_1_background_information.md} (68%) diff --git a/src/0_1_BackgroundInformation.md b/src/0_1_background_information.md similarity index 68% rename from src/0_1_BackgroundInformation.md rename to src/0_1_background_information.md index 5a36fce..b90075b 100644 --- a/src/0_1_BackgroundInformation.md +++ b/src/0_1_background_information.md @@ -35,5 +35,23 @@ Let's take a look at the size of some different pointer types in Rust. If we run the following code: ```rust +# use std::mem::size_of; +trait SomeTrait { + fn method(&self) { + todo!(); + } +} +fn main() { + println!("Size of Box: {}", size_of::>()); + println!("Size of &i32: {}", size_of::<&i32>()); + println!("Size of &Box: {}", size_of::<&Box>()); + println!("Size of Box: {}", size_of::>()); + println!("Size of &dyn Trait: {}", size_of::<&dyn SomeTrait>()); + println!("Size of Rc: {}", size_of::>()); + println!("Size of &[i32]: {}", size_of::<&[i32]>()); + println!("Size of &[&dyn Trait]: {}", size_of::<&[&dyn SomeTrait]>()); + println!("Size of [i32; 10]: {}", size_of::<[i32; 10]>()); + println!("Size of [&dyn Trait; 10]: {}", size_of::<[&dyn SomeTrait; 10]>()); +} ``` \ No newline at end of file diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 28ebeba..fc02471 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -1,4 +1,4 @@ # Summary -- [Introduction](./0_0_Introduction.md) -- [Some background information](./0_1_BackgroundInformation.md) +- [Introduction](./0_0_introduction.md) +- [Some background information](./0_1_background_information.md)