makepad/libs/relax/compiler/tests/box_from_cow.rs
Admin b22a714840 makepad run: the Rust JIT (libs/relax) and makepad-remote
The JIT that runs makepad apps from source: lexer, front end, type checker,
lazy borrow checker (Gandalf; `--check-first` opts in), codegen, session and
warm/cold caches keyed by compiler stamp, provided crates bound late,
startup images, live patching. User-facing name is `makepad run` (binary
`makepad`, MAKEPAD_RUN_* env, ~/.makepad-run); libs/relax stays the internal
library name. `makepad check` reports rustc-style diagnostics with rustc
error codes and checks a whole workspace (`--workspace`). Runs on macOS,
Linux, Windows and Android. makepad-remote: one tool schema for apps and the
WM (app/1): grabs, captures, traces, frame profiles and tweaks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 12:26:21 +02:00

17 lines
614 B
Rust

// alloc/src/boxed/convert.rs: Box<str> / Box<[T]> from a Cow (Scope's code_graph:
// `written: String::from_utf8_lossy(..).into()` into a Box<str> field)
use std::borrow::Cow;
#[test]
fn box_str_from_cow() {
let b: Box<str> = String::from_utf8_lossy(b"a.h").into();
assert_eq!(&*b, "a.h");
let o: Box<str> = Box::from(Cow::<str>::Owned(String::from("x")));
assert_eq!(&*o, "x");
}
#[test]
fn box_slice_from_cow() {
let b: Box<[u8]> = Cow::Borrowed(&[1u8, 2][..]).into();
assert_eq!(&*b, &[1, 2]);
let o: Box<[u8]> = Box::from(Cow::<[u8]>::Owned(vec![3]));
assert_eq!(&*o, &[3]);
}