@@ -659,6 +659,186 @@ impl Context {
659659 self . arena . get ( expr)
660660 }
661661
662+ /// Get the atom data for the given s-expression.
663+ ///
664+ /// This allows you to inspect s-expressions. If the s-expression is not an
665+ /// atom this function returns `None`.
666+ ///
667+ /// You may only pass in `SExpr`s that were created by this
668+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
669+ /// invalid data.
670+ pub fn get_atom ( & self , expr : SExpr ) -> Option < & str > {
671+ self . arena . get_atom ( expr)
672+ }
673+
674+ /// Get the string data for the given s-expression.
675+ ///
676+ /// This allows you to inspect s-expressions. If the s-expression is not an
677+ /// string this function returns `None`.
678+ ///
679+ /// You may only pass in `SExpr`s that were created by this
680+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
681+ /// invalid data.
682+ pub fn get_str ( & self , expr : SExpr ) -> Option < & str > {
683+ self . arena . get_str ( expr)
684+ }
685+
686+ /// Get the list data for the given s-expression.
687+ ///
688+ /// This allows you to inspect s-expressions.If the s-expression is not an
689+ /// list this function returns `None`.
690+ ///
691+ /// You may only pass in `SExpr`s that were created by this
692+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
693+ /// invalid data.
694+ pub fn get_list ( & self , expr : SExpr ) -> Option < & [ SExpr ] > {
695+ self . arena . get_list ( expr)
696+ }
697+
698+ /// Get the data for the given s-expression as an `u8`.
699+ ///
700+ /// This allows you to inspect s-expressions. If the s-expression is not an
701+ /// cannot be parsed into an `u8` this function returns `None`.
702+ ///
703+ /// You may only pass in `SExpr`s that were created by this
704+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
705+ /// invalid data.
706+ pub fn get_u8 ( & self , expr : SExpr ) -> Option < u8 > {
707+ self . arena . get_t ( expr)
708+ }
709+
710+ /// Get the data for the given s-expression as an `u16`.
711+ ///
712+ /// This allows you to inspect s-expressions. If the s-expression is not an
713+ /// cannot be parsed into an `u16` this function returns `None`.
714+ ///
715+ /// You may only pass in `SExpr`s that were created by this
716+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
717+ /// invalid data.
718+ pub fn get_u16 ( & self , expr : SExpr ) -> Option < u16 > {
719+ self . arena . get_t ( expr)
720+ }
721+
722+ /// Get the data for the given s-expression as an `u32`.
723+ ///
724+ /// This allows you to inspect s-expressions. If the s-expression is not an
725+ /// cannot be parsed into an `u32` this function returns `None`.
726+ ///
727+ /// You may only pass in `SExpr`s that were created by this
728+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
729+ /// invalid data.
730+ pub fn get_u32 ( & self , expr : SExpr ) -> Option < u32 > {
731+ self . arena . get_t ( expr)
732+ }
733+
734+ /// Get the data for the given s-expression as an `u64`.
735+ ///
736+ /// This allows you to inspect s-expressions. If the s-expression is not an
737+ /// cannot be parsed into an `u64` this function returns `None`.
738+ ///
739+ /// You may only pass in `SExpr`s that were created by this
740+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
741+ /// invalid data.
742+ pub fn get_u64 ( & self , expr : SExpr ) -> Option < u64 > {
743+ self . arena . get_t ( expr)
744+ }
745+
746+ /// Get the data for the given s-expression as an `u128`.
747+ ///
748+ /// This allows you to inspect s-expressions. If the s-expression is not an
749+ /// cannot be parsed into an `u128` this function returns `None`.
750+ ///
751+ /// You may only pass in `SExpr`s that were created by this
752+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
753+ /// invalid data.
754+ pub fn get_u128 ( & self , expr : SExpr ) -> Option < u128 > {
755+ self . arena . get_t ( expr)
756+ }
757+
758+ /// Get the data for the given s-expression as an `usize`.
759+ ///
760+ /// This allows you to inspect s-expressions. If the s-expression is not an
761+ /// cannot be parsed into an `usize` this function returns `None`.
762+ ///
763+ /// You may only pass in `SExpr`s that were created by this
764+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
765+ /// invalid data.
766+ pub fn get_usize ( & self , expr : SExpr ) -> Option < usize > {
767+ self . arena . get_t ( expr)
768+ }
769+
770+ /// Get the data for the given s-expression as an `i8`.
771+ ///
772+ /// This allows you to inspect s-expressions. If the s-expression is not an
773+ /// cannot be parsed into an `i8` this function returns `None`.
774+ ///
775+ /// You may only pass in `SExpr`s that were created by this
776+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
777+ /// invalid data.
778+ pub fn get_i8 ( & self , expr : SExpr ) -> Option < i8 > {
779+ self . arena . get_t ( expr)
780+ }
781+
782+ /// Get the data for the given s-expression as an `i16`.
783+ ///
784+ /// This allows you to inspect s-expressions. If the s-expression is not an
785+ /// cannot be parsed into an `i16` this function returns `None`.
786+ ///
787+ /// You may only pass in `SExpr`s that were created by this
788+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
789+ /// invalid data.
790+ pub fn get_i16 ( & self , expr : SExpr ) -> Option < i16 > {
791+ self . arena . get_t ( expr)
792+ }
793+
794+ /// Get the data for the given s-expression as an `i32`.
795+ ///
796+ /// This allows you to inspect s-expressions. If the s-expression is not an
797+ /// cannot be parsed into an `i32` this function returns `None`.
798+ ///
799+ /// You may only pass in `SExpr`s that were created by this
800+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
801+ /// invalid data.
802+ pub fn get_i32 ( & self , expr : SExpr ) -> Option < i32 > {
803+ self . arena . get_t ( expr)
804+ }
805+
806+ /// Get the data for the given s-expression as an `i64`.
807+ ///
808+ /// This allows you to inspect s-expressions. If the s-expression is not an
809+ /// cannot be parsed into an `i64` this function returns `None`.
810+ ///
811+ /// You may only pass in `SExpr`s that were created by this
812+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
813+ /// invalid data.
814+ pub fn get_i64 ( & self , expr : SExpr ) -> Option < i64 > {
815+ self . arena . get_t ( expr)
816+ }
817+
818+ /// Get the data for the given s-expression as an `i128`.
819+ ///
820+ /// This allows you to inspect s-expressions. If the s-expression is not an
821+ /// cannot be parsed into an `i128` this function returns `None`.
822+ ///
823+ /// You may only pass in `SExpr`s that were created by this
824+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
825+ /// invalid data.
826+ pub fn get_i128 ( & self , expr : SExpr ) -> Option < i128 > {
827+ self . arena . get_t ( expr)
828+ }
829+
830+ /// Get the data for the given s-expression as an `isize`.
831+ ///
832+ /// This allows you to inspect s-expressions. If the s-expression is not an
833+ /// cannot be parsed into an `isize` this function returns `None`.
834+ ///
835+ /// You may only pass in `SExpr`s that were created by this
836+ /// `Context`. Failure to do so is safe, but may trigger a panic or return
837+ /// invalid data.
838+ pub fn get_isize ( & self , expr : SExpr ) -> Option < isize > {
839+ self . arena . get_t ( expr)
840+ }
841+
662842 /// Access "known" atoms.
663843 ///
664844 /// This lets you skip the is-it-already-interned-or-not checks and hash map
0 commit comments