Function magnus::encoding::check

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

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

Returns Err if there is no common compatible encoding.

See also compatible.

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::check(a, b).unwrap().name(), "UTF-8");