better inline docs

main
Ziyang Hu 2 years ago
parent 4545fbfe0b
commit 3c83761ec6

@ -66,6 +66,7 @@ pub use storage::{Storage, StoreTx};
pub use crate::data::expr::Expr; pub use crate::data::expr::Expr;
use crate::data::json::JsonValue; use crate::data::json::JsonValue;
pub use crate::data::symb::Symbol; pub use crate::data::symb::Symbol;
pub use crate::parse::SourceSpan;
pub use crate::runtime::callback::CallbackOp; pub use crate::runtime::callback::CallbackOp;
pub use crate::runtime::db::Poison; pub use crate::runtime::db::Poison;

@ -6,12 +6,12 @@
* You can obtain one at https://mozilla.org/MPL/2.0/. * You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
use either::Either;
use std::cmp::{max, min}; use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet}; use std::collections::{BTreeMap, BTreeSet};
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
use std::sync::Arc; use std::sync::Arc;
use either::Either;
use miette::{bail, Diagnostic, IntoDiagnostic, Result}; use miette::{bail, Diagnostic, IntoDiagnostic, Result};
use pest::error::InputLocation; use pest::error::InputLocation;
use pest::Parser; use pest::Parser;
@ -104,7 +104,7 @@ impl ImperativeStmt {
if let Some(name) = prog.needs_write_lock() { if let Some(name) = prog.needs_write_lock() {
collector.insert(name); collector.insert(name);
} }
}, }
ImperativeStmt::If { ImperativeStmt::If {
condition, condition,
then_branch, then_branch,
@ -124,13 +124,13 @@ impl ImperativeStmt {
for prog in body { for prog in body {
prog.needs_write_locks(collector); prog.needs_write_locks(collector);
} }
}, }
ImperativeStmt::TempDebug { .. } ImperativeStmt::TempDebug { .. }
| ImperativeStmt::ReturnTemp { .. } | ImperativeStmt::ReturnTemp { .. }
| ImperativeStmt::Break { .. } | ImperativeStmt::Break { .. }
| ImperativeStmt::Continue { .. } | ImperativeStmt::Continue { .. }
| ImperativeStmt::ReturnNil { .. } | ImperativeStmt::ReturnNil { .. }
| ImperativeStmt::TempSwap { .. } => {}, | ImperativeStmt::TempSwap { .. } => {}
} }
} }
} }
@ -150,10 +150,11 @@ impl CozoScript {
} }
} }
/// Span of the element in the source script, with starting and ending positions.
#[derive( #[derive(
Eq, PartialEq, Debug, serde_derive::Serialize, serde_derive::Deserialize, Copy, Clone, Default, Eq, PartialEq, Debug, serde_derive::Serialize, serde_derive::Deserialize, Copy, Clone, Default,
)] )]
pub struct SourceSpan(pub(crate) usize, pub(crate) usize); pub struct SourceSpan(pub usize, pub usize);
impl Display for SourceSpan { impl Display for SourceSpan {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {

@ -203,9 +203,6 @@ impl<'s, S: Storage<'s>> Db<S> {
/// Export relations to JSON data. /// Export relations to JSON data.
/// ///
/// `relations` contains names of the stored relations to export. /// `relations` contains names of the stored relations to export.
///
/// If `as_objects` is `true`, then the output contains objects (maps) for each row,
/// otherwise the output contains arrays for each row, with headers attached separately.
pub fn export_relations<'a>( pub fn export_relations<'a>(
&'s self, &'s self,
relations: impl Iterator<Item = &'a str>, relations: impl Iterator<Item = &'a str>,

Loading…
Cancel
Save