Time: 0:00
Test a custom input to verify an edge case (e.g. empty lists, negative numbers, duplicates).
This bug belongs to the mutation and copying bugs pattern
Assignment does not copy, a shallow copy still shares its contents, and mutating methods return None.
What went wrong: The function attempted to slice a string at byte indices that do not align with character boundaries, causing a panic.
The fix: Adjust the slicing to use character indices instead of byte indices.
Remember: Always ensure string slices are made at character boundaries to avoid panics in Rust.
The pattern behind it: mutation and copying bugs.
Paste this into any web page or blog post. Visitors fix the bug right there, in their browser.
<iframe src="https://trybughunt.com/embed/59470271-a961-4331-9e2e-b5ef0d11a1d2" title="Debugging challenge: String slice panics on non-UTF-8 char boundary" width="100%" height="580" loading="lazy" style="border:1px solid #d4d4d8;border-radius:12px;max-width:760px"></iframe>
<p style="font-size:14px">Debugging challenge from <a href="https://trybughunt.com/challenges/59470271-a961-4331-9e2e-b5ef0d11a1d2">TryBugHunt</a></p>