17 Questions

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
let or const for $derived runes in Svelte?

Variables in JavaScript can be defined using either let or const (ignoring the antiquated [var](...

0 votes 7 views 1 Answer Asked 28 days ago
What is the difference between different HTTP status codes (301 vs 302 vs 307 vs 308)?

I'm working on building a web app and I'm a bit confused about the differences between HTTP status codes related to redirects, specifically 301, 302, 307, and 308. From what I understand, 301 and 302 are common older codes, but I keep seeing 307 and 308 i...

0 votes 6 views 1 Answer
Asked about 1 month ago
How to type props in Svelte 5?

I understand that in Svelte 4 and previous versions props are individually declared using export let name: type = defaultValue;. For example in Svelte 4: I'm also aware of the new $props rune in Svelte 5, however I don't understand how I can type the props using th...

0 votes 7 views 1 Answer Asked about 1 month ago
s
69
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 do I center an element horizontally and/or vertically with TailwindCSS?

How can I center an element horizontally and/or vertically in TailwindCSS? Is there more than one way to accomplish this, and if so, what are the pros and cons of each method and in what cases should they be used?

1 vote 9 views 1 Answer Asked about 1 month ago
w
79
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
When should I use Rc, Arc, or Box in Rust, and how do they differ in memory management?

I’m working on a Rust project and keep running into different smart pointer types like Rc, Arc, and Box. I understand they’re used for memory management, but I’m confused about the real-world scenarios for each. - When should I choose Rc over Arc, and vice-versa...

0 votes 8 views No Answers
Asked about 2 months ago
How can I deal with localStorage in SvelteKit SSR?

I'm building a Notice component that users can dismiss, and I'm storing the displayed state of the notice, however, I would like to preserve it across sessions. localStorage seems like a good way to accomplish this, however, when trying to use localStorage I get s...

0 votes 11 views 1 Answer Asked about 2 months ago
How to loop an each block a specific x number of times in Svelte?

I know of Svelte's {#each} block which allows you to iterate over arrays or array-likes. However, there are some cases where I'm not interested in the data of an array, but rather in repeating a block a specific x number of time...

0 votes 22 views 1 Answer Asked about 2 months ago
How to get epoch time in Rust?

How can I get the current system epoch time in milliseconds/seconds (and to a lesser extent nanoseconds and microseconds) in Rust?

1 vote 15 views 1 Answer
Asked about 2 months ago
w
79
How can I convert raw markdown to plaintext in TypeScript/JavaScript?

I'm working on adding structured data to question pages on solvin (more specifically implementing [QAPage](https://developers.google.com/search/docs/appearance/structured-data/qa...

0 votes 24 views 1 Answer Asked about 2 months ago
s
69
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
Font Size Inherit - Tailwind CSS

I would like to apply inherited font size to an element with Tailwind. I know that this can be achieved in regular CSS like so: But how would I accomplish this using purely Tailwind class syntax? text-inherit seems to apply color: inherit not font-size: inherit l...

1 vote 17 views 1 Answer Asked about 2 months ago
w
79
What is the difference between gap-x and space-x in TailwindCSS?

I’ve seen both gap-x/y-* and space-x/y-* used in Tailwind examples to create spacing between elements. What is the actual difference between them? Are they interchangeable, or is one preferable in certain situations?

2 votes 175 views 1 Answer Asked about 2 months ago
w
79
How to parse an integer from a string in Zig?

What is the proper way to parse an integer from a string in Zig, while being able to specify the resulting integer type? How would I convert foo to an i32, for example?

3 votes 45 views 1 Answer Asked about 2 months ago
J
J Early User
109