jdx / demand

prompt library for rust
https://docs.rs/demand
MIT License
52 stars 3 forks source link

run actions #49

Closed Vulpesx closed 4 months ago

Vulpesx commented 4 months ago

Spinner can do tricks now.

You can change the theme, style and name through a mpsc channel.

Had to make spinner own the Style and Theme to make this work, granted i didn't put any effort into this

The question at hand is what to do about themes, currently I just put it in a box to get this working, but that's not a good solution. We could:

I don't think owning the Style is nearly as much of a problem but should prob do the same with that as with Theme

Vulpesx commented 4 months ago

ill focus more on #48 so this one might take a while

Vulpesx commented 4 months ago

This version uses references and unsafe magic I forced the references to live longer than the scope, which means it has to reference data outside the closure you pass to run. If you make that data mutable u can change the theme and style without sending which kinda violates the borrow checker

In this particular case it isn't unsafe since it's mutating in place and the spinner doesn't hold on to a reference to any data that could be on the heap that I'm aware of.

However, if that's uncomfortable which it probably should be, it's really easy to disallow that