Name{...} 과 binding.Name{...} 만 있고 호출 뒤의 { 를 아무도 받지 않았다.
그래서 타입 인자를 명시한 리터럴이 파싱되지 않았고, 제네릭의 인스턴스는
Self{...} 나 생성자 함수로만 만들 수 있었다.
파서는 호출 뒤의 { 를 struct 리터럴로 받고, 체커는 그것을 타입 표기와 똑같은
resolver 에 넘긴다 -- 같은 철자니 같은 답이어야 한다. { 의 애매함은 이미
Name{...} 에 있던 것과 같고 같은 guard 가 정리한다.
hold.Cell(i32){ v: 7 } 다른 유닛의 제네릭
hold.Handle(Node){ raw: 3 } 본문에서 T 를 안 쓰는 것
Boxed(i32){ v: 9 } 이 유닛의 제네릭
미사용 타입 파라미터는 그대로 둔다. typed handle 이 바로 그 모양이고,
Handle(Node) 와 Handle(Kind) 가 실제로 다른 타입이라는 것은 badphant 가
거부로 고정한다.
233/233, 34/34.
15 lines
431 B
Plaintext
15 lines
431 B
Plaintext
unit hold;
|
|
|
|
// Fields are `pub` so another unit can write the literal directly. A generic
|
|
// with a `pub` field is the only way to reach `binding.Name(args){...}`.
|
|
pub struct Cell(T) {
|
|
pub v: T,
|
|
}
|
|
|
|
// `T` is never used in the body. That is the natural shape of a typed handle:
|
|
// the parameter is there to keep `Handle(Node)` and `Handle(Type)` apart, not
|
|
// to describe any storage.
|
|
pub struct Handle(T) {
|
|
pub raw: u32,
|
|
}
|