Struct rutie::RString[][src]

pub struct RString { /* fields omitted */ }

String

Methods

impl RString
[src]

Creates a new instance of Ruby String containing given string.

Examples

use rutie::{RString, VM};

let string = RString::new("Hello, World!");

assert_eq!(string.to_str(), "Hello, World!");

Ruby:

str = 'Hello, World!'

str == 'Hello, World!'

Creates a new instance of Ruby String, with UTF8 encoding, containing given string.

Examples

use rutie::{RString, VM};

let string = RString::new_utf8("Hello, World!");

assert_eq!(string.to_string(), "Hello, World!".to_string());

Ruby:

str = 'Hello, World!'

str == 'Hello, World!'

Retrieves underlying Rust String from Ruby String object.

Examples

use rutie::{RString, VM};

let string = RString::new("Hello, World!");

assert_eq!(string.to_string(), "Hello, World!".to_string());

Ruby:

str = 'Hello, World!'

str == 'Hello, World!'

Retrieves underlying Rust String from Ruby String object.

Unlike to_string() it does not perform any checks for internal null-bytes.

This function may be used to safely get binary data from Ruby.

Examples

use rutie::{RString, VM};

let string = RString::new("Hello,\0World!");

assert_eq!(string.to_string_unchecked(), "Hello,\0World!".to_string());

Ruby:

str = 'Hello,\0World!'

str == 'Hello,\0World!'

Important traits for Vec<u8>

Retrieves Vec<u8> from Ruby String object.

Unlike to_string() it does not perform any checks for internal null-bytes.

This function may be used to safely get binary data from Ruby.

Examples

use rutie::{RString, VM};

let string = RString::new("Hello,\0World!");

assert_eq!(string.to_vec_u8_unchecked(), (b"Hello,\0World!").to_vec());

Retrieves underlying &str from Ruby String object.

Examples

use rutie::{RString, VM};

let string = RString::new("Hello, World!");

assert_eq!(string.to_str(), "Hello, World!");

Ruby:

str = 'Hello, World!'

str == 'Hello, World!'

Retrieves underlying &str from Ruby String object.

Unlike to_str() it does not perform any checks for internal null-bytes.

This function may be used to safely get binary data from Ruby.

Examples

use rutie::{RString, VM};

let string = RString::new("Hello,\0World!");

assert_eq!(string.to_str_unchecked(), "Hello,\0World!");

Ruby:

str = 'Hello,\0World!'

str == 'Hello,\0World!'

Important traits for &'a [u8]

Retrieves underlying &[u8] from Ruby String object.

Unlike to_str() it does not perform any checks for internal null-bytes.

This function may be used to safely get binary data from Ruby.

Examples

use rutie::{RString, VM};

let string = RString::new("Hello,\0World!");

assert_eq!(string.to_bytes_unchecked(), b"Hello,\0World!");

Returns the length of the string in bytes

Examples

use rutie::{RString, VM};

let string = RString::new("Hello, World!");
let utf8_string = RString::new("⓯");

assert_eq!(string.bytesize(), 13);
assert_eq!(utf8_string.bytesize(), 3);

Ruby:

string = 'Hello, World!'
utf8_string = '⓯'

string.bytesize == 13
utf8_string.bytesize == 3

Appends a given string slice onto the end of this String.

Examples

use rutie::{RString, VM};

let mut string = RString::new("Hello, ");
string.concat("World!");

assert_eq!(string.to_string(), "Hello, World!".to_string());

Ruby:

str = 'Hello, '
str << 'World!'

str == 'Hello, World!'

Trait Implementations

impl Debug for RString
[src]

Formats the value using the given formatter. Read more

impl PartialEq for RString
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl From<Value> for RString
[src]

Performs the conversion.

impl From<String> for RString
[src]

Performs the conversion.

impl Object for RString
[src]

Returns internal value of current object. Read more

Returns a class of current object. Read more

Returns a singleton class of current object. Read more

Important traits for &'a mut R

Gets an immutable reference to the Rust structure which is wrapped into a Ruby object. Read more

Important traits for &'a mut R

Gets a mutable reference to the Rust structure which is wrapped into a Ruby object.

Important traits for &'a mut R

Wraps calls to the object. Read more

Defines an instance method for the given class or object. Read more

Defines a private instance method for the given class or object. Read more

Defines a class method for given class or singleton method for object. Read more

An alias for define_method (similar to Ruby syntax def some_method).

An alias for define_private_method (similar to Ruby syntax private def some_method).

An alias for define_singleton_method (similar to Ruby def self.some_method).

Calls a given method on an object similarly to Ruby Object#send method Read more

Alias for Ruby's == Read more

Alias for Ruby's === Read more

Alias for Ruby's eql? Read more

Alias for Ruby's equal? Read more

Checks whether the object responds to given method Read more

protect_send returns Result<AnyObject, AnyObject> Read more

protect_public_send returns Result<AnyObject, AnyObject> Read more

Checks whether the object is nil Read more

Converts struct to AnyObject Read more

Gets an instance variable of object Read more

Sets an instance variable for object Read more

Returns the freeze status of the object. Read more

Prevents further modifications to the object. Read more

Unsafely casts current object to the specified Ruby type Read more

Safely casts current object to the specified Ruby type Read more

Determines the value type of the object Read more

impl VerifiedObject for RString
[src]

Auto Trait Implementations

impl Send for RString

impl Sync for RString