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

Rust 수업 노트 요약본 배포 #64

Open
hilyun07 opened this issue Dec 13, 2023 · 0 comments
Open

Rust 수업 노트 요약본 배포 #64

hilyun07 opened this issue Dec 13, 2023 · 0 comments
Labels

Comments

@hilyun07
Copy link
Contributor

FIX: Only reference types, not Box types, can have a lifetime annotation; specifically, only &'a T or &'a mut T are allowed.

  1. storage vs. value
  2. storage has a mutability flag
  3. A storage of type T contains and owns a value of type T in it
  4. A value can own a storage
    • (v: Box<T>) refers to and owns a storage of type T
  5. A value can borrow a storage with or without mutability
    • (v: &T) refers to and reads from a storage of type T
    • (v: &mut T) refers to and reads from / writes to a storage of type T
  6. Lifetime analysis: static vs. dynamic (RC or ARC)
    • A borrowed reference should not live longer than the owner.
  7. Sharing XOR Mutation analysis: static vs. dynamic (Refcell or Mutex)
    • Sharing and mutation to a storage cannot happen at the same time.
  8. Unsized (or Dynamically-Sized) types
  9. Struct (field access)
  10. Enum (pattern match)
  11. Generic Types are monomorphized since the size of varies for each T.
  12. "impl TR" returns a concrete type implementing the trait TR but hides the type information from the programmer.
  13. Lifetime annotation <'a> only comes with reference (ie, borrowed) types (&'a T or &'a mut T) but NOT Box types (Box<T>).
    • This is because the lifetimes of borrowed types are determined by their owners
      while the lifetimes of all the other types including box types are determined by myself (ie, not shared with others).
  14. The interpretation of lifetime annotations depends on what are input references and what are output references.
    • Every lifetime consistent with the input references should be consistent with the output references.
@hilyun07 hilyun07 added the announcement 공지 label Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant