-
Notifications
You must be signed in to change notification settings - Fork 140
Add Rust version 1.33.0 #690
Comments
Yeah, I've been wanting to add a newer version and get rid of 1.15. Rust on Codewars was originally contributed by the community, then I rewrote it so we can use Cargo while keeping it compatible (#466). So 1.15 on Codewars is a hack. When I added 1.25, I removed most of the hacks and that's why it's not compatible. See Rust wiki page for the differences. Also, the test output is manually parsed and it's not standardized so this changes between versions. I've been waiting for the JSON output that was proposed years ago, but I don't think it's been finalized yet :( It's more work than it seems. |
I see. Thanks for the feedback. |
I just created a new wiki page of a list of Rust 1.15 kata to be updated. We currently have |
Great, I'll get to it. :) |
I wish to help. However, I see no way to translate a kata from one Rust version to another. How one can do it? |
@hedgehog1024 Thanks :) You've completed "Don't give me five!" so I'll use that for example. When changing language version, we usually just do it by editing kata. So open the kata editor by clicking "Edit Kata". (EDIT: See "Coauthor Kata" in Privileges if you don't see "Edit Kata". You might not have enough honor points or you might need to let others know by making a suggestion comment.) The original test looks like the following: // At the moment random tests are not possible for RUST
// https://github.com/Codewars/codewars-runner-cli/issues/240
#[test]
fn basic_tests() {
assert_eq!(dont_give_me_five(1, 9), 8);
assert_eq!(dont_give_me_five(4, 17), 12);
}
#[test]
fn advanced_tests() {
assert_eq!(dont_give_me_five(1, 90), 72);
assert_eq!(dont_give_me_five(-4, 17), 20);
assert_eq!(dont_give_me_five(-4, 37), 38);
assert_eq!(dont_give_me_five(-14, -1), 13);
assert_eq!(dont_give_me_five(-14, -6), 9);
} (BTW, it's possible to add random tests even on 1.15) To change this to make it compatible with 1.25, we need to put them inside a child module #[cfg(test)]
mod tests {
use dont_give_me_five; // or use super::*;
// TODO add random tests
#[test]
fn basic_tests() {
assert_eq!(dont_give_me_five(1, 9), 8);
assert_eq!(dont_give_me_five(4, 17), 12);
}
#[test]
fn advanced_tests() {
assert_eq!(dont_give_me_five(1, 90), 72);
assert_eq!(dont_give_me_five(-4, 17), 20);
assert_eq!(dont_give_me_five(-4, 37), 38);
assert_eq!(dont_give_me_five(-14, -1), 13);
assert_eq!(dont_give_me_five(-14, -6), 9);
}
} + #[cfg(test)]
+ mod tests {
+ use dont_give_me_five;
+ } You can verify this by clicking "Validate Solution" after changing the language version to 1.25. Don't forget to also update the "Example Test Cases". When you're done, just click "Re-Publish" (this might take some time to finish). To use crates like #[cfg(test)]
extern crate rand;
#[cfg(test)]
mod tests {
use add; // function to test
use rand;
use rand::distributions::{IndependentSample, Range};
#[test]
fn returns_sum() {
let between = Range::new(1, 10);
let mut rng = rand::thread_rng();
let x = between.ind_sample(&mut rng);
let y = between.ind_sample(&mut rng);
assert_eq!(add(x, y), x + y);
}
} |
You're right. I completely forgot about that :( You need 4000 honor points. See this table. |
Grinding time! |
@kazk are you positive 4000 honor points is the only requirement? I still can't edit katas the way you described it. |
@LesnyRumcajs 4000 honor points should be the only requirement from a user. It should show "Edit Kata" if you have 4000 points and the kata doesn't have contribution disabled. It can be a cache issue if you had loaded that page before. Can you try if "Edit Kata" shows on other kata? |
@kazk Ya, I relogged, cleared the cache and checked out even from a different machine. Strangely I hadn't received any notification about my new super powers when passed 4k. |
@LesnyRumcajs Something might be broken. It'll be tracked on codewars/codewars.com#1723 |
@kazk Okay, I'm starting to update the katas. If I can't edit it (no issues in past week, contributing disabled), should I add an issue so the kata author will do it himself / herself (or wait till I can do it myself)? |
@LesnyRumcajs Thanks! Something like:
That's what the other user helping to update Haskell is doing. |
@LesnyRumcajs I think I can add Rust 1.32 soon (luckily the test output looks the same). The only issue I've found so far is I'll probably wait for Rust 1.33 (2019-02-28) though. I hope changes from 1.32 doesn't affect us. For future versions, I'd like to have at most 2 versions at the same time. We can add a new version when all of the kata using older versions are updated to newer one. I'm going to make 1.33 an exception because 1.15 is a huge hack and requires larger effort to update to 1.25. So for now we can have versions:
Next step is to drop 1.15 by updating existing kata using it to 1.25+:
Then, before adding another version, I'll ask the community to update any kata using older version to newer one so we can drop the older one. I'll help with making a list of kata to update and also run a script to update them if it's compatible without code change. If we need significant change for some reason, I'll consider adding a version temporarily. |
Hi @kazk is there a way to help creators of Katas to move from 1.15 to newer ones, or they need to do that themselves? |
@bartsmykla You can help by following @kazk guide here: #690 (comment) |
@bartsmykla Thanks. You can also post a comment suggesting an update and maybe others can help. See #690 (comment) |
Added Rust 1.33! I ran a script to update compatible kata to use 1.33 and looks like we have 164 kata with 1.33 enabled. |
Please complete the following information:
Couldn't find a better category. It would be nice to have newest Rust available on Codewars. It would be even nicer if existing katas would have access to this new Rust version (or at least 1.25). Katas created with Rust 1.15 are most probably finishable with higher version of Rust because of it's renowned backward compatibility (they run tests with major crates to check this, I guess katas are not as complicated as Diesel, Serde or Hyper. It makes me a little bit sad when I finish writing the code, get compiler error, and finally notice that the particular kata is for 1.15 exclusively.
👍 reaction might help.
The text was updated successfully, but these errors were encountered: