transmute is semantically equivalent to a bitwise move of one type into another. It copies the bits from the source value into the destination value, then forgets the original. It’s equivalent to C’s memcpy under the hood, just like transmute_copy .
Only in the sense that every function call allocates memory: When you call a function, the compiler allocates some space in the caller's stack frame to hold the return value; the output of transmute is stored there, just like any other return value would be.
(NB: This is greatly simplified from the real process; small values might stay in registers and never touch memory, for example.)
The transmute in as_bytes takes a fat pointer (&str) and returns a fat pointer (&[u8]). A fat pointer is exactly two regular pointers big, so it it was a regular call as_bytes would take it in two registers and return it in two registers. The function body would at most shuffle the registers around if necessary when optimizations are enabled. However because as_bytes is marked as #[inline(always)], it will optimize to a no-op.
No, the compiler may optimize the memcpy away and in fact likely will for small values in favor of passing it around in registers if there are free registers.