leo_std/lib.rs
1// Copyright (C) 2019-2026 Provable Inc.
2// This file is part of the Leo library.
3
4// The Leo library is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// The Leo library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
16
17//! Embedded source for the Leo standard library.
18//!
19//! Compiler and tooling crates depend on this to inject `std` into every
20//! Leo build without requiring users to declare it in `program.json`.
21
22/// The Leo identifier under which the standard library is exposed
23/// (`std::foo(...)`).
24pub const LIBRARY_NAME: &str = "std";
25
26const LIB_LEO: &str = include_str!("leo/lib.leo");
27const DUMMY_LEO: &str = include_str!("leo/dummy.leo");
28
29/// Entry source of the standard library (contents of `lib.leo`).
30pub fn entry_source() -> &'static str {
31 LIB_LEO
32}
33
34/// Submodule sources, returned as `(virtual_path, source)` pairs.
35///
36/// The format matches what `leo_compiler::Compiler::build_library` expects:
37/// the first element of each tuple is a label used in span/error reporting,
38/// and the second is the Leo source for that submodule.
39pub fn modules() -> &'static [(&'static str, &'static str)] {
40 &[("dummy.leo", DUMMY_LEO)]
41}
42
43/// The Leo identifier under which the standard library is exposed.
44pub fn library_name() -> &'static str {
45 LIBRARY_NAME
46}