pub fn copy<T, U>(dst: T, src: U) -> Result<(), Error> where
    T: EncodingCapable,
    U: EncodingCapable
Expand description

Compies the encoding from src to dst.

This does not reconcode dst.

Similar to EncodingCapable::enc_associate, except takes the encoding of src rather than an encoding object or index.

Examples

use magnus::{encoding::{self, EncodingCapable}, RString};

let a = RString::new("a");
assert!(a.enc_get() == encoding::Index::utf8());
let b = RString::new("b");
assert!(b.enc_get() == encoding::Index::utf8());

a.enc_set(encoding::Index::usascii());
encoding::copy(b, a).unwrap();

assert!(b.enc_get() == encoding::Index::usascii());