pub(crate) fn vec_map B>(v: &Vec, f: F) -> Vec { v.iter().map(f).collect::>() } pub(crate) fn vec_map_result(v: &Vec, f: F) -> Result, C> where F: FnMut(&A) -> Result, { v.iter().map(f).collect::, C>>() } static VERUS_GITHUB_BUG_REPORT_URL: std::sync::RwLock>> = std::sync::RwLock::new(None); pub fn set_verus_github_bug_report_url(s: String) { *VERUS_GITHUB_BUG_REPORT_URL.write().unwrap() = Some(std::sync::Arc::new(s)); } #[inline(always)] pub fn get_verus_github_bug_report_url() -> Option> { VERUS_GITHUB_BUG_REPORT_URL.read().unwrap().clone() } pub(crate) fn err_span>( span: crate::messages::Span, msg: S, ) -> Result { Err(crate::messages::error(&span, msg)) } pub fn internal_err_span( span: crate::messages::Span, msg: String, ) -> Result { Err(crate::messages::internal_error(&span, msg)) } #[macro_export] macro_rules! internal_err { ($span: expr, $msg: expr) => {{ $crate::util::internal_err_span($span, $msg.to_string())?; unreachable!() }}; ($span: expr, $msg: expr, $info: expr) => {{ dbg!($info); $crate::util::internal_err_span($span, $msg.to_string())?; unreachable!() }}; } #[allow(unused_macros)] macro_rules! dbg_backtrace { ($val: expr) => { match $val { tmp => { std::eprintln!( "[{}:{}:{}] {} = {:#?}", std::file!(), std::line!(), std::column!(), std::stringify!($val), &tmp ); eprintln!( "[{}:{}:{}]\n{}", std::file!(), std::line!(), std::column!(), std::backtrace::Backtrace::force_capture() ); tmp } } }; } #[allow(unused_imports)] pub(crate) use dbg_backtrace; #[allow(unused_macros)] macro_rules! backtrace { () => { eprintln!( "[{}:{}:{}]\n{}", std::file!(), std::line!(), std::column!(), std::backtrace::Backtrace::force_capture() ); }; } #[allow(unused_imports)] pub(crate) use backtrace;