Function magnus::encoding::compatible

source ·
pub fn compatible<T, U>(v1: T, v2: U) -> Option<RbEncoding>where
    T: EncodingCapable,
    U: EncodingCapable,
Expand description

Returns the common encoding between v1 and v2, or None.

Returns None if there is no common compatible encoding.

See also check.

Examples

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

let a = RString::new("a");
let b = RString::new("b");

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

assert_eq!(encoding::compatible(a, b).unwrap().name(), "UTF-8");