1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

strconv: mark strconv.v_sprintf and strconv.v_printf with [unsafe] (part 2, breaking change, needed an update to vsl) (#18836)

This commit is contained in:
Delyan Angelov 2023-07-10 21:20:47 +03:00 committed by GitHub
parent 6b00685629
commit acd581add5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,8 +27,9 @@ enum Char_parse_state {
// Note, that this function is unsafe.
// In most cases, you are better off using V's string interpolation,
// when your format string is known at compile time.
fn v_printf(str string, pt ...voidptr) {
print(v_sprintf(str, ...pt))
[unsafe]
pub fn v_printf(str string, pt ...voidptr) {
print(unsafe { v_sprintf(str, ...pt) })
}
// v_sprintf returns a sprintf-like formated `string`.
@ -41,7 +42,7 @@ fn v_printf(str string, pt ...voidptr) {
// x := 3.141516
// assert strconv.v_sprintf('aaa %G', x) == 'aaa 3.141516'
// ```
[direct_array_access; manualfree]
[direct_array_access; manualfree; unsafe]
pub fn v_sprintf(str string, pt ...voidptr) string {
mut res := strings.new_builder(pt.len * 16)
defer {