https://pantsbuild.org/ logo
#development
Title
# development
h

hundreds-breakfast-49010

09/12/2019, 9:00 PM
is there a good example of creating a python
datatype
from scratch in rust code?
a

aloof-angle-91616

09/12/2019, 9:01 PM
we usually call the function
create_*
that we get when initializing the scheduler, and provide arguments to that
h

hundreds-breakfast-49010

09/12/2019, 9:02 PM
ah, like
construct_directory_digest
?
and it looks like that gets invoked in rust with
externs::unsafe_call
a

aloof-angle-91616

09/12/2019, 9:02 PM
yes!
h

hundreds-breakfast-49010

09/12/2019, 11:00 PM
related question: how much extra stuff on top of the standard rust futures crate is pants using?
at the moment I'm trying to figure out how to lift a
Value
into a
Future
so my code typechecks
and I don't know if I start looking at the crate docs how much I'll be misled
by whatever custom stuff pants is doing
a

aloof-angle-91616

09/12/2019, 11:01 PM
future::ok()
, which may already be available as
ok()
depending upon which file you're in
what do you mean by custom stuff
h

hundreds-breakfast-49010

09/12/2019, 11:02 PM
like, if there are any pants-specific macros or what have you that are used pervasively around the crate imports
I don't know the futures API super-well
a

aloof-angle-91616

09/12/2019, 11:02 PM
i don't think so
h

hundreds-breakfast-49010

09/12/2019, 11:02 PM
ok
a

aloof-angle-91616

09/12/2019, 11:03 PM
like there's
future::ok()
and then you just
.map()
,
.and_then()
, and then you have to call
.to_boxed()
at the end to make it a
BoxedFuture
oh
sorry
there is indeed a subcrate
boxed_future
i haven't looked in it at all
a

average-vr-56795

09/13/2019, 9:38 AM
Magic on top we have: •
BoxFuture<Item, Error>
is just an alias for
Box<Future<Item=Item, Error=Error> + Send
try_future!
is like the
try!
macro (which is the same as the
?
operator), but which returns a
BoxFuture
rather than a
Result
(i.e. if its argument is an error, it early-returns a
BoxFuture<_, Error>
of that error, else it unwraps the
Ok(T)
to a
T
Otherwise we’re pretty standard