Closed enaut closed 3 years ago
Merging #231 (ea891b3) into master (60dba16) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #231 +/- ##
=======================================
Coverage 61.17% 61.17%
=======================================
Files 40 40
Lines 2697 2697
=======================================
Hits 1650 1650
Misses 1047 1047
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 60dba16...ea891b3. Read the comment docs.
Should all be done now... do these builds also build the examples? Asking because I'd like to stay compatible with everything...
Sorry I could have sworn I tested it... but obviously i forgot to save or something... I did not manage to get the choose function to work without importing the trait... I made this clearer in the comment.
I was a bit too busy this weekend so I haven't gotten to this yet. Will try to review soon. :)
I did not manage to get the choose function to work without importing the trait... I made this clearer in the comment.
To do this you need to import the choose
function, not use the choose
method. Run cargo doc --open
to see the docs for the turtle::rand
module. Unfortunately the version on docs.rs/turtle does not reflect the current API.
Hope that helps!
To do this you need to import the
choose
function, not use thechoose
method. Runcargo doc --open
to see the docs for theturtle::rand
module. Unfortunately the version on docs.rs/turtle does not reflect the current API.
This is what I did... however that would require &str to implement Random (at least the compiler says so...) which cannot be done because str is not fixed size.
the not working lines are (tried in different permuttations):
let secret: &str = turtle::rand::choose(WORDS).expect("Failed to choose a random word.");
The only way I managed to get this working is by creating a vec from the fixed size array and choose from that - I dislike that and find my original solution much cleaner.
let secret: &str = turtle::rand::choose(&WORDS.to_vec()).expect("Failed to choose a random word.");
Ooo looks like there is a bug on the random slice implementations for fixed sized arrays that is forcing the type stored in the array to implement Random. I'll fix that shortly. In the meantime changing the type of WORDS
to &[&str]
instead of &[&str; 28]
will allow you to use the function version of choose. The method version was essentially coercing to that type anyway. Sorry about that!
I just merged in #236 with the fix so if you rebase you may not even need to change the type in order to use the function. Let me know if you run into any further issues. :)
New things:
rand.choose
functionHey! Really sorry for not getting to your PR yet. Going through some things and will try to find time soon. I usually try to be really quick with these things, but it unfortunately didn't work out this time. I will get to this! :)
If you want to we could go through this on discord or similar... that might be faster than writing everything...
Just merged in master. This PR can be merged as soon as the build passes.
Thanks!
working:
I think I have a rough idea about how to solve the non bold ones... the bold ones I could only do by "stealing" from the other pull request (#226).
references: #227
things would be much nicer if #22 and #60 would be implemented