Skip to content

Conversation

@lonesometraveler
Copy link
Contributor

Now, this is not a simple clippy fix. I think you want to split a &str with ':' and ',' and take out &strs that represent f32. This PR should do that. Here is a set of simple tests I used. If I am missing something, please let me know.

#[test] fn test_split() { let input = "foo: bar, baz, qux: -0.1, 0.2, -0.3"; let expected_output = vec!["-0.1", "0.2", "-0.3"]; let actual_output = split(input); assert_eq!(expected_output, actual_output); } #[test] fn test_split_2() { let input = "foo:bar,baz,qux:-0.1,0.2,-0.3"; let expected_output = vec!["-0.1", "0.2", "-0.3"]; let actual_output = split(input); assert_eq!(expected_output, actual_output); }

I think we should parse in this function and return Vec<f32> instead of Vec<&str>. But that requires modification in main. Let's make sure we are good with this change first.

@hacknus
Copy link
Owner

hacknus commented Feb 18, 2023

Yes, perfect! This looks much cleaner and seems to work. I agree about returning f32 and adapt main().

@hacknus hacknus merged commit 4591214 into hacknus:main Feb 18, 2023
@lonesometraveler
Copy link
Contributor Author

Cool. I will send more PRs tomorrow.

@lonesometraveler lonesometraveler deleted the refactor_split branch February 28, 2023 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants