Ushering out strlcpy()
Ushering out strlcpy()
Posted Aug 30, 2022 15:43 UTC (Tue) by excors (subscriber, #95769)In reply to: Ushering out strlcpy() by andy_shev
Parent article: Ushering out strlcpy()
The Rust standard library isn't fully suitable for use in a kernel (or many other embedded environments), but that's okay, you can find or implement your own equivalent types that meet your requirements (just like you'd have to when using C). E.g. there's heapless::String (https://docs.rs/heapless/latest/heapless/struct.String.html) as a fixed-capacity string without dynamic allocation, where functions that might exceed the string's capacity (like String::push) return a Result<> so it's always safe and the caller has to explicitly decide how to handle that case.