--- a/crates/jrsonnet-interner/src/lib.rs +++ b/crates/jrsonnet-interner/src/lib.rs @@ -6,7 +6,7 @@ #![warn(clippy::pedantic, clippy::nursery)] #![allow(clippy::missing_const_for_fn)] use std::{ - borrow::Cow, + borrow::{Borrow, Cow}, cell::RefCell, fmt::{self, Display}, hash::{BuildHasherDefault, Hash, Hasher}, @@ -57,6 +57,17 @@ } } +impl Borrow for IStr { + fn borrow(&self) -> &str { + self.as_str() + } +} +impl Borrow<[u8]> for IStr { + fn borrow(&self) -> &[u8] { + self.as_bytes() + } +} + impl PartialEq for IStr { fn eq(&self, other: &Self) -> bool { // all IStr should be inlined into same pool @@ -135,6 +146,12 @@ } } +impl Borrow<[u8]> for IBytes { + fn borrow(&self) -> &[u8] { + self.0.as_slice() + } +} + impl PartialEq for IBytes { fn eq(&self, other: &Self) -> bool { // all IStr should be inlined into same pool --- a/crates/jrsonnet-stdlib/src/misc.rs +++ b/crates/jrsonnet-stdlib/src/misc.rs @@ -3,6 +3,7 @@ use jrsonnet_evaluator::{ error::{ErrorKind::*, Result}, function::{builtin, ArgLike, CallLocation, FuncVal}, + manifest::JsonFormat, throw, typed::{Either2, Either4}, val::{equals, ArrValue},