question-mark

Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Write a Rust program to split string into array of words

See original GitHub issue

Issue Description

Description

Write a Rust program to split string into array of words

Input  : "hello world"
Output : ["hello", "world"]
How to contribute
  • Save the solution in split_string_into_array_of_words.rs file
  • Add split_string_into_array_of_words.rs file in program/split-string-into-array-of-words folder

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
hugosmoreiracommented, Dec 11, 2022

@harshraj8843 I just did thank you for the help, I was trying to use vscode but I failed I will try to practice more

1reaction
hugosmoreiracommented, Dec 11, 2022

fn split_string(s: &str) -> Vec<&str> { s.split_whitespace().collect() }

fn main() { let s = “hello world”; let words = split_string(s); println!(“{:?}”, words); }

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I split a string in Rust?
Split a (character) string into comma (plus a blank) delimited strings based on a change of character (left to right).
Read more >
How to Split a String in Rust? (Explained with Examples)
To split a string slice or type &str in Rust, use the split() method to create an iterator. Once the iterator is generated,...
Read more >
How to Use Split String in the Rust Language
This article provides a guide on using Split String in the Rust Language. In this tutorial, we highlight the various methods, such as...
Read more >
Split in std::str
Returns remainder of the split string ... type Item = &'a str. The type of the ... Advances the iterator and returns an...
Read more >
Rust Tutorial => Split a string
Rust Strings Split a string​​ let strings = "bananas,apples,pear". split(","); split returns an iterator. And can be "collected" in a Vec with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found