Draft RFC: variadic generics
<a href="https://github.com/eddyb"><img src="https://avatars.githubusercontent.com/u/77424?v=2" align="left" width="96" height="96" hspace="10"></img></a> **Issue by [eddyb](https://github.com/eddyb)** _Monday Oct 28, 2013 at 17:39 GMT_ _For earlier discussion, see https://github.com/rust-lang/rust/issues/10124_ _This issue was labelled with: B-RFC in the Rust repository_ --- ## The Problem - [fn types need a reform](http://smallcultfollowing.com/babysteps/blog/2013/10/10/fn-types-in-rust/), and being able to define a trait with a variable number of type parameters would help - working with functions which have a variable number of arguments is impossible right now (e.g. a generic `bind` method, `f.bind(a, b)(c) == f(a, b, c)`) and defining such functions may only be done (in a limited fashion) with macros - tuples also have similar restrictions right now, there is no way to define a function which takes any tuple and returns the first element, for example ## The Solution: Part One C++11 sets a decent precedent, with its variadic templates, which can be used to define type-safe variadic functions, among other things. I propose a similar syntax, a trailing `..T` in generic formal type parameters: ``` rust type Tuple<..T> = (..T); // the parens here are the same as the ones around a tuple. // use => expansion Tuple<> => () Tuple<int> => (int,) Tuple<A, B, C> => (A, B, C) ``` The simple example above only uses `..T`, but not `T` itself. The question which arises is this: w
Posted by rust-highfive on Oct 8, 2014, 11:34 PM
Tags
Related issues
- [Meta] Feedback on granular control over Copilot changes
- unexpected status 401 Unauthorized issue
- [MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
- [CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
- Video stops playing after some minutes
- [MODEL] Claude verbose code comments by default — ignores instructions to stop.
Raise real-world problems, find people facing the same issue, and discuss solutions.9,000 issues0 comments
github (Software)
[Meta] Feedback on granular control over Copilot changes
unexpected status 401 Unauthorized issue
[MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
[CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
Video stops playing after some minutes
[MODEL] Claude verbose code comments by default — ignores instructions to stop.
Scope Codex VS Code chats to the current workspace/project
Update on "Co-authored-by: Copilot" in commit messages
Draft RFC: variadic generics
<a href="https://github.com/eddyb"><img src="https://avatars.githubusercontent.com/u/77424?v=2" align="left" width="96" height="96" hspace="10"></img></a> **Issue by [eddyb](https://github.com/eddyb)** _Monday Oct 28, 2013 at 17:39 GMT_ _For earlier discussion, see https://github.com/rust-lang/rust/issues/10124_ _This issue was labelled with: B-RFC in the Rust repository_ --- ## The Problem - [fn types need a reform](http://smallcultfollowing.com/babysteps/blog/2013/10/10/fn-types-in-rust/), and being able to define a trait with a variable number of type parameters would help - working with functions which have a variable number of arguments is impossible right now (e.g. a generic `bind` method, `f.bind(a, b)(c) == f(a, b, c)`) and defining such functions may only be done (in a limited fashion) with macros - tuples also have similar restrictions right now, there is no way to define a function which takes any tuple and returns the first element, for example ## The Solution: Part One C++11 sets a decent precedent, with its variadic templates, which can be used to define type-safe variadic functions, among other things. I propose a similar syntax, a trailing `..T` in generic formal type parameters: ``` rust type Tuple<..T> = (..T); // the parens here are the same as the ones around a tuple. // use => expansion Tuple<> => () Tuple<int> => (int,) Tuple<A, B, C> => (A, B, C) ``` The simple example above only uses `..T`, but not `T` itself. The question which arises is this: w
Comments (0)
No comments yet. Start the discussion.