difftreelog
feat impl Borrow for IStr/IBytes
in: master
2 files changed
crates/jrsonnet-interner/src/lib.rsdiffbeforeafterboth--- 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<str> 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
crates/jrsonnet-stdlib/src/misc.rsdiffbeforeafterboth3use jrsonnet_evaluator::{3use jrsonnet_evaluator::{4 error::{ErrorKind::*, Result},4 error::{ErrorKind::*, Result},5 function::{builtin, ArgLike, CallLocation, FuncVal},5 function::{builtin, ArgLike, CallLocation, FuncVal},6 manifest::JsonFormat,6 throw,7 throw,7 typed::{Either2, Either4},8 typed::{Either2, Either4},8 val::{equals, ArrValue},9 val::{equals, ArrValue},