[][src]Function rosy::vm::require_with

pub unsafe fn require_with(file: impl Into<String>, safe_level: c_int) -> bool

Loads file with safe_level, without checking for exceptions.

This returns true if successful or false if already loaded.

If the filename does not resolve to an absolute path, it will be searched for in the directories listed in$LOAD_PATH ($:).

If the filename has the extension .rb, it is loaded as a source file; if the extension is .so, .o, or .dll, or the default shared library extension on the current platform, Ruby loads the shared library as a Ruby extension. Otherwise, Ruby tries adding .rb, .so, and so on to the name until found. If the file named cannot be found, a LoadError will be returned.

For Ruby extensions the filename given may use any shared library extension. For example, on Linux the socket extension is socket.so and require 'socket.dll' will load the socket extension.

The absolute path of the loaded file is added to $LOADED_FEATURES ($"). A file will not be loaded again if its path already appears in $". For example, require 'a'; require './a' will not load a.rb again.

require "my-library.rb"
require "db-driver"

Any constants or globals within the loaded source file will be available in the calling program's global namespace. However, local variables will not be propagated to the loading environment.

Safety

Code executed from file may void the type safety of objects accessible from Rust. For example, if one calls push on Array<A> with an object of type B, then the inserted object will be treated as being of type A.

An exception may be raised by the code in file or by file being invalid.