These are chat archives for rust-lang/rust

28th
Jan 2017
Kibeom Kim
@kkimdev
Jan 28 2017 00:16
@KalitaAlexey I can't think of a practical value of single determined drop behavior, but if that's preferable, another way is making all drops as early as possible.
Actually, I can't think of practical code that I would want to delay drop... and even if there are such instances, if dropping early is better for most cases, maybe it makes sense to do that by default.
Kibeom Kim
@kkimdev
Jan 28 2017 00:21
Either ways, users still have control when to drop, by {} or explicitly calling std::ops::Drop
Kibeom Kim
@kkimdev
Jan 28 2017 00:30
OK here is the discussion about it few years ago rust-lang/rfcs#239
Alexander Ronald Altman
@pthariensflame
Jan 28 2017 09:16
You have explicit control anyway; that's what mem::drop is for.
Robin Lambertz
@roblabla
Jan 28 2017 11:25
Hey. I'm having a small problem defining a lifetime of a fn pointer in a lazy_static. https://play.rust-lang.org/?gist=f3a3c2942ce65d5991a6307cdb1fd4a3&version=stable&backtrace=0 It complains that 'a is not defined in the lazy_static macro, but I have no idea where to define it :(
Aleksey Kladov
@matklad
Jan 28 2017 11:36
Robin Lambertz
@roblabla
Jan 28 2017 11:36
Woah. Never saw that syntax.
Aleksey Kladov
@matklad
Jan 28 2017 12:36
@roblabla yep, it is rarely used. Some info can be fond in https://doc.rust-lang.org/nomicon/hrtb.html. Basically, when you use just <'a>, you say that your function works for some particular lifetime 'a, and when you say for<'a> you say that the function can handle any lifetime.
Jarred Nicholls
@jnicholls
Jan 28 2017 18:23
futures question: if I want a function that takes mutable reference to an object, and returns a Future...inside the function I do some async stuffs and ultimately want the result of the async operations to mutate the object through that mutable reference, before completing the Future for the caller of the function. What would be the best or better way to
1:10 PM design that API? Essentially something like this, but obviously not exactly: https://gist.github.com/jnicholls/8a22471f77ffa3c06c21200bcbc91cb1
Aleksey Kladov
@matklad
Jan 28 2017 18:26
@jnicholls I think https://gitter.im/tokio-rs/tokio might be a more specific gitter channel for this question
Jarred Nicholls
@jnicholls
Jan 28 2017 18:26
fair
thx
James Lucas
@AtheMathmo
Jan 28 2017 19:44
Are there any guides or resources for writing compiler plugins? I've found this page: https://doc.rust-lang.org/book/compiler-plugins.html but I was hoping for a little more nitty gritty
Aleksey Kladov
@matklad
Jan 28 2017 19:45
@AtheMathmo have you seen syn: https://github.com/dtolnay/syn#complete-example?
James Lucas
@AtheMathmo
Jan 28 2017 19:49
I haven't. Taking a look now but I'm not sure if it would cover what I need. I need to take a function and break it down into primitive blocks. i.e. f(x) = 1 + x^2 = g(h(x), 1). g = 1 + h, h(x) = x ^ 2
where f is defined in native rust code, and I can build a computation graph out of the primitive blocks