Struct passerine::common::source::Source[][src]

pub struct Source {
    pub contents: String,
    pub path: PathBuf,
}

Source represents some literal source code. Whether a repl session, a file on disk, or some library code. It’s essentially a string with a path, the path serving as the source’s name. Source files without a path point to ./source, though this behaviour might change in the future.

Fields

contents: Stringpath: PathBuf

Implementations

impl Source[src]

pub fn new(source: &str, path: &Path) -> Rc<Source>[src]

Creates a new Source given both an &str and a PathBuf. Note that this function does not check that the contents of the file match the source. Source::path or Source::source should be used instead.

pub fn path(path: &Path) -> Result<Rc<Source>>[src]

Build a Source from a path. This will read a file to create a new source.

pub fn source(source: &str) -> Rc<Source>[src]

Build an empty Source containing just a string. Note that this source will point towards ./source.

Trait Implementations

impl Debug for Source[src]

impl Eq for Source[src]

impl PartialEq<Source> for Source[src]

impl StructuralEq for Source[src]

impl StructuralPartialEq for Source[src]

Auto Trait Implementations

impl RefUnwindSafe for Source

impl Send for Source

impl Sync for Source

impl Unpin for Source

impl UnwindSafe for Source

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.