These are chat archives for rust-lang/rust

Feb 2017
Maciej Hirsz
Feb 14 2017 11:43
any clue if this is actually possible to declare in Rust:
fn foo_func<'a>(bar: &Bar<'a>) -> Baz<'a> {
    // ...

const FOO: fn(&Bar<'a>) -> Baz<'a> = foo_func;
making a const or static reference to a function that is itself operating on types with lifetimes
I understand why I can't use any lifetime other than 'static for all things static or const, in this case however the lifetime doesn't refer to what FOO holds, but what that thing it holds operates on, which should be safe
Ed Lewis
Feb 14 2017 11:46
why would you want to do that?
Aleksey Kladov
Feb 14 2017 11:47
const FOO: for<'a> fn(&Bar<'a>) -> Baz<'a> = foo_func;
Maciej Hirsz
Feb 14 2017 11:47
I've a lookup table that calls a different function per byte of input
thanks @matklad, will try!
yap, worked perfectly, thanks again
Sasha Hilton
Feb 14 2017 12:00
is there an easy way to crossfade stuff in rust in the form of a crate? Or should I just handle that stuff in also?
Mike Lubinets
Feb 14 2017 20:08

Hello. I'm currently playing around shm in linux and i'm wondering if it's possible to write a custom allocator so one can use std::collections::* within multiple processes.
Writing allocator is not a problem, as far as I can see, but I'm not sure if it's possible to use SHM allocator only when I need it.

Can I choose which allocator to use in rust? Maybe there is some hack such as reimporting std::collections in new crate linked to custom allocator or something like that?

To be clear: I don't want every allocation to be performed with shm, just a few
Peter Atashian
Feb 14 2017 20:36
@mersinvald There's no way to have a custom allocator for specific collections at the moment. You'd have to write your own collection types that use your custom allocator
Mike Lubinets
Feb 14 2017 21:21
@retep998 thanks! Very unfortunate. Do you know if there are any plans to improve allocators in rust?
Peter Atashian
Feb 14 2017 21:54
@mersinvald There are plans. You can search through the rfc repo for stuff relating to allocators
Mike Lubinets
Feb 14 2017 21:55
@retep998 ok, thanks again (: