You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
str.trim() copies; it should be a view like trim_start/trim_end (D71, D105) #2225
str.trim() is the STR_TRIM intrinsic over with_str_trim_ref, which allocates an owned copy (rt_core.w: "#747: owned copy, never a view", written before D71 made s[a..b] a &str view). D105 (#2206) added trim_start()/trim_end() as views (-> &str, O(1), no allocation), so trim is now the odd one out and the only one that allocates.
Make trim a view too: -> &str over the same ASCII whitespace set, spelled in one place with the other two (an impl str method in std.string, retiring the intrinsic), and migrate the callers that hold the result as an owned str (.to_owned() where an owned value is actually needed). The runtime function retires with the intrinsic.
Spec: none; the no-implicit-copy rule and D71 already decide it. Decision log: D105.
Fixed in 60e53a2 (stack #2251): str.trim() is a view (pub fn trim() -> &str in lib/std/string.w; the STR_TRIM intrinsic is gone from Sema, codegen and the evaluator). test/behavior/behav_2225_trim_is_a_view.w and test/compile_errors/err_2225_view_of_temporary_receiver.w pin it; the callee temporary-view rule (§21.1) refuses temp().trim() escaping its statement.
Activity
std.string: str.rfind, trim_start/trim_end as views, bytes() (D105, #…
str.trim() is a view; the evaluator runs std str bodies and slices st…
Sema: corpus-private std modules (#2248); str.trim() is a view, the e…
ehartford commentedon Oct 7, 2026
Fixed in 60e53a2 (stack #2251):
str.trim()is a view (pub fn trim() -> &strin lib/std/string.w; the STR_TRIM intrinsic is gone from Sema, codegen and the evaluator). test/behavior/behav_2225_trim_is_a_view.w and test/compile_errors/err_2225_view_of_temporary_receiver.w pin it; the callee temporary-view rule (§21.1) refusestemp().trim()escaping its statement.Pin the joint seed nightly-20261025-local-1 and retire the seed-bound…
Sema: a binding or inferred return of a view into a statement tempora…
Sema: a binding or inferred return of a view into a statement tempora…