string
0 Followers 5 Questions Created 3 months ago

A sequence of characters used to represent text in programming. Strings are fundamental in nearly all languages and support operations like concatenation, searching, and formatting.

How to split a string into chunks in Rust and insert spaces (or another character)?

I'm working with hexadecimal strings and I want to insert a space between every two characters in a string so that each byte can be easily distinguished. I'm aware that chunks and join could be used, but no such methods are available in [Chars](https://doc.rust-lan...

0 votes 3 views 1 Answer Asked 3 days ago
J
J Early User
109
How to compare strings in Zig?

I'm learning Zig and want to know the proper way to compare strings. I see that strings are slices ([]const u8), but how do I: - Check if two strings are equal - Do a case-insensitive comparison What functions or standard library utilities should I use for these common...

0 votes 3 views No Answers Asked about 1 month ago
J
J Early User
109
How can I convert an integer to a string in Zig?

Forgive me but I'm pretty new to Zig and need to convert an integer (e.g. i32) into a string for display purposes. What's the idiomatic way to do this in Zig at runtime, and are there different approaches depending on the integer type or allocation needs?

1 vote 14 views 1 Answer Asked about 2 months ago
J
J Early User
109
How can I concatenate strings in Rust?

How can I perform string concatenation with &str String, and the various combinations you can make with them (&str and &str, String and String, etc.) in Rust?

0 votes 7 views 1 Answer Asked about 2 months ago
J
J Early User
109
Should I write string function arguments as &str, String, AsRef<str>, or Into<String> in Rust?

I'm developing a public Rust library and I'm unsure how to handle function parameters that deal with strings. There seem to be multiple idiomatic options: - &str - String - impl AsRef<str> - impl Into<String> Each of these works in different cases, but I don't u...

2 votes 25 views 1 Answer Asked about 2 months ago