Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the useful suggestions from reddit #2

Closed
usagi opened this issue Aug 21, 2020 · 5 comments
Closed

Include the useful suggestions from reddit #2

usagi opened this issue Aug 21, 2020 · 5 comments

Comments

@usagi
Copy link
Owner

usagi commented Aug 21, 2020

From: https://www.reddit.com/r/rust/comments/idwlqu/rust_memory_container_cheatsheet_publish_on_github/g2bsbso/?utm_source=reddit&utm_medium=web2x&context=3

Internal sharing? -[no]--> Allocates? -[no]--> Internal mutability? -[no]--> Ownership? -[no]-----------------------------------> &mut T
      \                     \                                    \                     `-[yes]----------------------------------> T
       \                     \                                    \
        \                     \                                    `-[yes]-> Thread-safe? -[no]--> Internal references? -[no]---> Cell<T>
         \                     \                                                       \                               `-[yes]--> RefCell<T>
          \                     \                                                       \
           \                     \                                                       `-[yes]-> Internal references? -[no]---> AtomicT
            \                     \                                                                                  \ `-[one]--> Mutex<T>
             \                     \                                                                                  `--[many]-> RwLock<T>
              \                     \
               \                     `-[yes]------------------------------------------------------------------------------------> Box<T>
                \         
                 `-[yes]-> Allocates? -[no]-------------------------------------------------------------------------------------> &T
                                    \
                                     `-[yes]-> Thread-safe? -[no]---------------------------------------------------------------> Rc<T>
                                                           `-[yes]--------------------------------------------------------------> Arc<T>
Reply

And, I have an interest to several suggestions for a correctness or details. But, the cheat-sheet favor to a newbiews, and the right columns is not a type, yes I know. I'll make an update with include these reddit users suggestions to the rev1 or a later.

@usagi usagi added this to the rev.1 milestone Aug 21, 2020
@usagi usagi self-assigned this Aug 21, 2020
@usagi
Copy link
Owner Author

usagi commented Aug 22, 2020

Working draft, rev.1-alpha

image

@usagi
Copy link
Owner Author

usagi commented Aug 22, 2020

Working draft, rev.1-beta

image

@foobles
Copy link

foobles commented Aug 22, 2020

Cell<T> and RefCell<T> should be moved to the stack-allocation section. Those types do not do any heap allocs whatsoever.

@usagi
Copy link
Owner Author

usagi commented Aug 22, 2020

@theInkSquid Oh that's right, it was my mistaken. I'll fixup soon. Very thank you🙏

@usagi
Copy link
Owner Author

usagi commented Aug 22, 2020

Working draft, rev.1-gamma

image

usagi added a commit that referenced this issue Aug 22, 2020
- #2, #2 (comment)
- #1, tune the contrast and make script for generate variants automatic
@usagi usagi mentioned this issue Aug 22, 2020
Merged
@usagi usagi closed this as completed in 1645a05 Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants