MCPcopy Create free account
hub / github.com/chanced/jsonptr / qc_split

Function qc_split

src/pointer.rs:1994–2069  ·  view source on GitHub ↗
(ptr: PointerBuf)

Source from the content-addressed store, hash-verified

1992
1993 #[quickcheck]
1994 fn qc_split(ptr: PointerBuf) -> bool {
1995 if let Some((head, tail)) = ptr.split_front() {
1996 {
1997 let Some(first) = ptr.first() else {
1998 return false;
1999 };
2000 if first != head {
2001 return false;
2002 }
2003 }
2004 {
2005 let mut copy = ptr.clone();
2006 copy.pop_front();
2007 if copy != tail {
2008 return false;
2009 }
2010 }
2011 {
2012 let mut buf = tail.to_buf();
2013 buf.push_front(head.clone());
2014 if buf != ptr {
2015 return false;
2016 }
2017 }
2018 {
2019 let fmt = alloc::format!("/{}{tail}", head.encoded());
2020 if Pointer::parse(&fmt).unwrap() != ptr {
2021 return false;
2022 }
2023 }
2024 } else {
2025 return ptr.is_root()
2026 && ptr.count() == 0
2027 && ptr.last().is_none()
2028 && ptr.first().is_none();
2029 }
2030 if let Some((head, tail)) = ptr.split_back() {
2031 {
2032 let Some(last) = ptr.last() else {
2033 return false;
2034 };
2035 if last != tail {
2036 return false;
2037 }
2038 }
2039 {
2040 let mut copy = ptr.clone();
2041 copy.pop_back();
2042 if copy != head {
2043 return false;
2044 }
2045 }
2046 {
2047 let mut buf = head.to_buf();
2048 buf.push_back(tail.clone());
2049 if buf != ptr {
2050 return false;
2051 }

Callers

nothing calls this directly

Calls 13

parseFunction · 0.85
split_frontMethod · 0.80
firstMethod · 0.80
pop_frontMethod · 0.80
to_bufMethod · 0.80
push_frontMethod · 0.80
is_rootMethod · 0.80
countMethod · 0.80
lastMethod · 0.80
split_backMethod · 0.80
pop_backMethod · 0.80
push_backMethod · 0.80

Tested by

no test coverage detected