Skip to main content

RFromStr

Trait RFromStr 

Source
pub trait RFromStr: Sized {
    // Required method
    fn from_str(s: &str) -> Option<Self>;
}
Expand description

Adapter trait for std::str::FromStr.

Provides string parsing for R, allowing R strings to be parsed into Rust types. Automatically implemented for any type that implements FromStr.

§Methods

  • from_str(s: &str) - Parse a string into this type, returning None on failure

§Example

use std::net::IpAddr;

// IpAddr implements FromStr
#[derive(ExternalPtr)]
struct IpAddress(IpAddr);

#[miniextendr]
impl RFromStr for IpAddress {}

In R:

ip <- IpAddress$from_str("192.168.1.1")

Required Methods§

Source

fn from_str(s: &str) -> Option<Self>

Parse a string into this type.

Returns Some(value) on success, None on parse failure. The None case maps to NULL in R.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: FromStr> RFromStr for T