Skip to content

Instantly share code, notes, and snippets.

@vsajip
Forked from rust-play/playground.rs
Created October 18, 2018 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsajip/11f93e8ab92865c73cc3b6f16fbb3602 to your computer and use it in GitHub Desktop.
Save vsajip/11f93e8ab92865c73cc3b6f16fbb3602 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
use std::io::{BufRead};
struct Processor<B: BufRead> {
reader: B
}
// If you uncomment p in ValidatorA, compilation fails because the size of
// ValidatorA can't be determined at compile time. Fair enough.
struct ValidatorA {
// p : Processor<BufRead>
}
// In ValidatorB, compilation fails for the same reason as above - but why?
// Aren't references a fixed size - a sort of fat pointer, if you will?
struct ValidatorB<'a> {
p : &'a Processor<BufRead>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment