Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for Fn traits (`unboxed_closures` feature) #29625
Comments
aturon
added
T-lang
B-unstable
labels
Nov 5, 2015
alexcrichton
added
the
T-libs
label
Mar 7, 2016
This comment has been minimized.
This comment has been minimized.
|
Inability to delegate calls to other FnOnce implementors like this: struct A<T>(T);
impl<T, Args> FnOnce<Args> for A<T>
where T: FnOnce<Args> {
type Output = <T as FnOnce<Args>>::Output;
fn call_once(self, args: Args) -> Self::Output { FnOnce::call_once(self.0, args) }
}is the reason I have a safety issue in libloading. |
nagisa
referenced this issue
May 13, 2016
Open
Cloning Dereferenced symbol may cause undefined behaviour. #13
This comment has been minimized.
This comment has been minimized.
|
|
nagisa
referenced this issue
Jul 17, 2016
Closed
`Fn`s with different arguments should be different types #34868
This comment has been minimized.
This comment has been minimized.
|
Could someone summarise what is blocking stabilisation here please? |
This comment has been minimized.
This comment has been minimized.
|
@nrc uncertainty about |
PlasmaPower
referenced this issue
Aug 22, 2016
Closed
We want to be able to use an implementation of `Filter<N>` as function. #5
This comment has been minimized.
This comment has been minimized.
nrc
added
the
B-RFC-implemented
label
Aug 29, 2016
gyscos
referenced this issue
Feb 5, 2017
Closed
Consider making EditView::on_edit take an FnMut #108
shepmaster
referenced this issue
Jun 18, 2017
Open
Cannot call implementations of the `Fn*` traits on references #42736
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
eternaleye
referenced this issue
Oct 24, 2017
Open
`FnOnce` doesn't seem to support type-based dispatch (as `Add`, etc. do) #45510
This comment has been minimized.
This comment has been minimized.
brunoczim
commented
Jan 18, 2018
|
There should be a way of casting |
This comment has been minimized.
This comment has been minimized.
|
@brunoczim That coercion already happens implicitly, but use std::rc::Rc;
fn main() {
let _: &Fn() = &main;
let _: Box<Fn()> = Box::new(main);
let _: Rc<Fn()> = Rc::new(main);
} |
This comment has been minimized.
This comment has been minimized.
Michael-F-Bryan
commented
Apr 2, 2018
|
One issue we've been discussing on TheDan64/inkwell#5 is the ability to mark something as For context, |
This comment has been minimized.
This comment has been minimized.
CodeSandwich
commented
May 4, 2018
•
|
There is another reason to add
|
This comment has been minimized.
This comment has been minimized.
|
@Michael-F-Bryan @CodeSandwich This sounds like something for which an RFC would really be appreciated. It probably wouldn't be an overly long or intricate one to write, even. I would support it, for sure, and judging by an issue I saw about this not long ago (a long-standing one), others would too. |
This comment has been minimized.
This comment has been minimized.
CodeSandwich
commented
Aug 21, 2018
|
@alexreg Ok, I'll prepare it in spare time. Unfortunately I lack knowledge and experience to actually implement it or even fully understand the idea. |
This comment has been minimized.
This comment has been minimized.
|
@CodeSandwich Don't worry, so do I! Maybe get yourself on Rust's Discord (#design channel) and we can discuss it with some people who really know the nitty gritty? You can ping me there, same username. |
This comment has been minimized.
This comment has been minimized.
|
With every unsafe function comes a manually written "contract" saying when that function may or may not be called. With |
This comment has been minimized.
This comment has been minimized.
Michael-F-Bryan
commented
Aug 23, 2018
I'd say this is done on a case-by-case basis. It's really hard to specify the various invariants and assumptions you make in Before writing up a RFC I thought I'd make a post on the internal forum. It'd be nice to hear what opinions other people have on this topic and the different solutions they come up with. |
This comment has been minimized.
This comment has been minimized.
Vurich
commented
Nov 5, 2018
|
I don't know how one would realistically implement this, but probably the ideal semantics is to have any function that takes an |
This comment has been minimized.
This comment has been minimized.
|
A different interface/API likely requires a separate set of traits. Though multiplying the number of traits doesn’t sound great, especially if we later want to also support |
This comment has been minimized.
This comment has been minimized.
illustrious-you
commented
Nov 6, 2018
•
|
Is there a way to implement these as wrapper traits? |
This comment has been minimized.
This comment has been minimized.
|
Personally, I think For example, CodeSandwich's example can be "fixed" using a closure: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=308c3ee61419427c617879fc4cb82738 |
This comment has been minimized.
This comment has been minimized.
|
I agree. |
This comment has been minimized.
This comment has been minimized.
brunoczim
commented
Feb 13, 2019
|
I understand the argument against |
This comment has been minimized.
This comment has been minimized.
Yes, I would say so. |
aturon commentedNov 5, 2015
•
edited by nikomatsakis
Tracks stabilization for the
Fn*traits.Random bugs:
foo()sugar doesn't work where you have&Foo: FnOnce