-
Notifications
You must be signed in to change notification settings - Fork 8
Type annotations required everywhere #5
Comments
You can try it out using https://github.com/95th/bumpalo |
I think in the below code (and other places), we should accept
|
But |
More reduced example: This doesn't work:
This works:
But weirdly, this one works too:
|
I'm not at home atm, so I'll only do a quick response:
```
let mut v: Vec<_,> = Vec::new_in(AbortAlloc(Global));
```
works, as it's the same as `Vec<T>` and this defaults to `Vec<T, AbortAlloc<Global>`
However I'm aware of the required Annotation as `BuildAlloc` and `AllocRef` are not the same, but both are implemented for `AbortAlloc<Global>`, and I don't like it. A better API which solves this is highly welcome :)
…On Nov 9, 2019, 17:14, at 17:14, Gurwinder Singh ***@***.***> wrote:
More reduced example:
This doesn't work:
```
use alloc_wg::vec::Vec;
use alloc_wg::alloc::{Global, AbortAlloc};
fn main() {
let mut v = Vec::new_in(AbortAlloc(Global));
v.push("String");
}
```
This works:
```
use alloc_wg::vec::Vec;
use alloc_wg::alloc::{Global, AbortAlloc};
fn main() {
let mut v: Vec<_, AbortAlloc<Global>> =
Vec::new_in(AbortAlloc(Global));
v.push("String");
}
```
But weirdly, this one works too:
```
use alloc_wg::vec::Vec;
use alloc_wg::alloc::{Global, AbortAlloc};
fn main() {
let mut v: Vec<_,> = Vec::new_in(AbortAlloc(Global));
v.push("String");
}
```
Probably some bug in rust.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#5 (comment)
|
I'm currently thinking of another advantages:
downsides:
It would also be possible to change |
Inference is good but then we have two kinds of methods. Is it possible to provide getter for |
Something like:
|
Please take a look at https://github.com/95th/alloc-wg |
Then this works:
|
I think this is the best solution possible 🙂 |
Awesome. Thanks |
The allocator generic Vec constructors ask for type annotations everywhere.
and I get:
This applies to all constructors of Vec type (and String type I am working on).
I can get around that by specifying:
But it's annoying to do it everywhere. Is it possible to have inferred?
The text was updated successfully, but these errors were encountered: