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:
parent
6b00685629
commit
acd581add5
@ -27,8 +27,9 @@ enum Char_parse_state {
|
|||||||
// Note, that this function is unsafe.
|
// Note, that this function is unsafe.
|
||||||
// In most cases, you are better off using V's string interpolation,
|
// In most cases, you are better off using V's string interpolation,
|
||||||
// when your format string is known at compile time.
|
// when your format string is known at compile time.
|
||||||
fn v_printf(str string, pt ...voidptr) {
|
[unsafe]
|
||||||
print(v_sprintf(str, ...pt))
|
pub fn v_printf(str string, pt ...voidptr) {
|
||||||
|
print(unsafe { v_sprintf(str, ...pt) })
|
||||||
}
|
}
|
||||||
|
|
||||||
// v_sprintf returns a sprintf-like formated `string`.
|
// v_sprintf returns a sprintf-like formated `string`.
|
||||||
@ -41,7 +42,7 @@ fn v_printf(str string, pt ...voidptr) {
|
|||||||
// x := 3.141516
|
// x := 3.141516
|
||||||
// assert strconv.v_sprintf('aaa %G', x) == 'aaa 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 {
|
pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
mut res := strings.new_builder(pt.len * 16)
|
mut res := strings.new_builder(pt.len * 16)
|
||||||
defer {
|
defer {
|
||||||
|
Loading…
Reference in New Issue
Block a user