id
stringlengths
20
30
source
stringclasses
1 value
chunk_index
int64
0
520k
token_count
int32
154
512
content
stringlengths
185
57.5k
rust_dataset_chunk_2200
rust_dataset.txt
2,200
512
Ok(()) } } struct Indented<'a, D> { inner: &'a mut D, number: Option<usize>, started: bool, } impl<T> Write for Indented<'_, T> where T: Write, { fn write_str(&mut self, s: &str) -> fmt::Result { for (i, line) in s.split('\n').enumerate() { if !self.started { ...
rust_dataset_chunk_2201
rust_dataset.txt
2,201
512
! is given a single expr argument to turn into anyhow::Error, we // want the resulting Error to pick up the input's implementation of source() // and backtrace() if it has a std::error::Error impl, otherwise require nothing // more than Display and Debug. // // Expressed in terms of specialization, we want something li...
rust_dataset_chunk_2202
rust_dataset.txt
2,202
512
#[cold] pub fn new<M>(self, message: M) -> Error where M: Display + Debug + Send + Sync + 'static, { Error::construct_from_adhoc(message, backtrace!()) } } pub struct Trait; #[doc(hidden)] pub trait TraitKind: Sized { #[inline] fn anyhow_kind(&self) -> Trait { Trait...
rust_dataset_chunk_2203
rust_dataset.txt
2,203
512
anyhow::Error`][Error], a trait object based error //! type for easy idiomatic error handling in Rust applications. //! //! <br> //! //! # Details //! //! - Use `Result<T, anyhow::Error>`, or equivalently `anyhow::Result<T>`, as //! the return type of any fallible function. //! //! Within the function, use `?` to e...
rust_dataset_chunk_2204
rust_dataset.txt
2,204
512
to read instrs from {}", path))?; //! # //! # const _: &str = stringify! { //! ... //! # }; //! # //! # Ok(()) //! } //! ``` //! //! ```console //! Error: Failed to read instrs from ./path/to/instrs.json //! //! Caused by: //! No such file or directory (os error 2) /...
rust_dataset_chunk_2205
rust_dataset.txt
2,205
512
ics to have backtraces, set `RUST_BACKTRACE=1` and //! `RUST_LIB_BACKTRACE=0`. //! //! [`std::backtrace`]: std::backtrace#environment-variables //! //! - Anyhow works with any error type that has an impl of `std::error::Error`, //! including ones defined in your crate. We do not bundle a `derive(Error)` //! m...
rust_dataset_chunk_2206
rust_dataset.txt
2,206
512
require an additional //! `.map_err(Error::msg)` when working with a non-Anyhow error type inside a //! function that returns Anyhow's error type, as the trait that `?`-based error //! conversions are defined by is only available in std in those old versions. #![doc(html_root_url = "https://docs.rs/anyhow/1.0.104")] ...
rust_dataset_chunk_2207
rust_dataset.txt
2,207
512
Error; #[cfg(all(not(feature = "std"), anyhow_no_core_error))] trait StdError: Debug + Display { fn source(&self) -> Option<&(dyn StdError + 'static)> { None } } #[doc(no_inline)] pub use anyhow as format_err; /// The `Error` type, a wrapper around a dynamic error type. /// /// `Error` works a lot li...
rust_dataset_chunk_2208
rust_dataset.txt
2,208
512
/// 1: core::result::Result<T,E>::map_err /// at /git/rustc/src/libcore/result.rs:596 /// 2: anyhow::context::<impl anyhow::Context<T,E> for core::result::Result<T,E>>::with_context /// at /git/anyhow/src/context.rs:58 /// 3: testing::main /// at src/main.rs:5 /// 4: ...
rust_dataset_chunk_2209
rust_dataset.txt
2,209
512
} /// ``` #[cfg(any(feature = "std", not(anyhow_no_core_error)))] #[derive(Clone)] pub struct Chain<'a> { state: crate::chain::ChainState<'a>, } /// `Result<T, Error>` /// /// This is a reasonable return type to use throughout your application but also /// for `fn main`; if you do, failures will be printed along ...
rust_dataset_chunk_2210
rust_dataset.txt
2,210
512
self) -> Result<()> {...} /// # }; /// # fn detach(&mut self) -> Result<()> { /// # unimplemented!() /// # } /// } /// /// pub fn do_it(mut it: ImportantThing) -> Result<Vec<u8>> { /// it.detach().context("Failed to detach the important thing")?; /// /// let path = &it.path; /// let con...
rust_dataset_chunk_2211
rust_dataset.txt
2,211
512
Result}; /// /// fn do_it() -> Result<()> { /// helper().context("Failed to complete the work")?; /// # const IGNORE: &str = stringify! { /// ... /// # }; /// # unreachable!() /// } /// /// fn main() { /// let err = do_it().unwrap_err(); /// if let So...
rust_dataset_chunk_2212
rust_dataset.txt
2,212
512
only once an error does occur. fn with_context<C, F>(self, f: F) -> Result<T, Error> where C: Display + Send + Sync + 'static, F: FnOnce() -> C; } /// Equivalent to `Ok::<_, anyhow::Error>(value)`. /// /// This simplifies creation of an `anyhow::Result` in places where type /// inference canno...
rust_dataset_chunk_2213
rust_dataset.txt
2,213
512
_str() { // anyhow!("literal"), can downcast to &'static str Error::msg(message) } else { // anyhow!("interpolate {var}"), can downcast to String Error::msg(fmt::format(args)) } } #[doc(hidden)] #[inline] #[cold] #[must_use] pub fn...
rust_dataset_chunk_2214
rust_dataset.txt
2,214
512
# let depth = 0; /// # /// if depth > MAX_DEPTH { /// bail!(ScienceError::RecursionLimitExceeded); /// } /// # Ok(()) /// # } /// ``` #[macro_export] #[cfg_attr(not(anyhow_no_clippy_format_args), clippy::format_args)] macro_rules! bail { ($msg:literal $(,)?) => { return $crate::__private::Err($...
rust_dataset_chunk_2215
rust_dataset.txt
2,215
512
/// # }, 1).1, /// } /// /// # fn main() -> Result<()> { /// # let depth = 0; /// # /// ensure!(depth <= MAX_DEPTH, ScienceError::RecursionLimitExceeded); /// # Ok(()) /// # } /// ``` $ensure }; } #[cfg(doc)] __ensure![ ...
rust_dataset_chunk_2216
rust_dataset.txt
2,216
512
type implements `std::error::Error` /// (in addition to `Debug` and `Display`, which are always required), then that /// Error impl's `source` is preserved as the `source` of the resulting /// `anyhow::Error`. /// /// # Example /// /// ``` /// # type V = (); /// # /// use anyhow::{anyhow, Result}; /// /// fn lookup(ke...
rust_dataset_chunk_2217
rust_dataset.txt
2,217
512
. If the current toolchain is able to compile it, then // anyhow is able to provide backtrace support. #![cfg_attr(anyhow_build_probe, feature(error_generic_member_access))] use core::error::{self, Error}; use std::backtrace::Backtrace; pub use core::error::Request; #[cfg(anyhow_build_probe)] const _: () = { us...
rust_dataset_chunk_2218
rust_dataset.txt
2,218
512
<T> where T: ?Sized, { fn clone(&self) -> Self { *self } } impl<T> Own<T> where T: ?Sized, { pub fn new(ptr: Box<T>) -> Self { Own { ptr: NonNull::from(Box::leak(ptr)), } } pub fn cast<U: CastTo>(self) -> Own<U::Target> { Own { ptr: s...
rust_dataset_chunk_2219
rust_dataset.txt
2,219
512
} } } #[repr(transparent)] pub struct Mut<'a, T> where T: ?Sized, { pub ptr: NonNull<T>, lifetime: PhantomData<&'a mut T>, } impl<'a, T> Copy for Mut<'a, T> where T: ?Sized {} impl<'a, T> Clone for Mut<'a, T> where T: ?Sized, { fn clone(&self) -> Self { *self } } impl<'a, T> Mut...
rust_dataset_chunk_2220
rust_dataset.txt
2,220
512
-> fmt::Result { Display::fmt(&self.0, f) } } impl<M> StdError for MessageError<M> where M: Display + Debug + 'static {} #[repr(transparent)] pub struct DisplayError<M>(pub M); impl<M> Debug for DisplayError<M> where M: Display, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Di...
rust_dataset_chunk_2221
rust_dataset.txt
2,221
512
#[rustversion::attr(not(nightly), ignore = "requires nightly")] #[cfg_attr(miri, ignore = "incompatible with miri")] #[test] fn ui() { let t = trybuild::TestCases::new(); t.compile_fail("tests/ui/*.rs"); } --- FILE: anyhow/tests/crate/test.rs --- #![no_std] pub use anyhow::*; --- FILE: anyhow/tests/drop/mo...
rust_dataset_chunk_2222
rust_dataset.txt
2,222
512
wind_safe::<Error>(); } #[test] fn test_unpin() { fn assert_unpin<T: Unpin>() {} assert_unpin::<Error>(); } --- FILE: anyhow/tests/test_backtrace.rs --- #![allow(clippy::let_underscore_untyped)] #[rustversion::not(nightly)] #[ignore = "requires nightly"] #[test] fn test_backtrace() {} #[rustversion::nightl...
rust_dataset_chunk_2223
rust_dataset.txt
2,223
512
()); assert_eq!("1", chain.next().unwrap().to_string()); assert_eq!("0", chain.next().unwrap().to_string()); assert!(chain.next().is_none()); assert!(chain.next_back().is_none()); } #[test] fn test_rev() { let e = error(); let mut chain = e.chain().rev(); assert_eq!("0", chain.next().unwrap...
rust_dataset_chunk_2224
rust_dataset.txt
2,224
512
ippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 clippy::nonstandard_macro_braces, )] mod drop; use crate::drop::{DetectDrop, Flag}; use anyhow::{Context, Error, Result}; use std::fmt::{self, Display}; use thiserror::Error; // https://github.com/dtolnay/anyhow/issues/18 #[test] fn test_inference() ...
rust_dataset_chunk_2225
rust_dataset.txt
2,225
512
pped.high), }) .unwrap_err(); (high, dropped) } #[test] fn test_downcast_ref() { let (err, dropped) = make_chain(); assert!(!err.is::<String>()); assert!(err.downcast_ref::<String>().is_none()); assert!(err.is::<HighLevel>()); let high = err.downcast_ref::<HighLevel>().unwrap...
rust_dataset_chunk_2226
rust_dataset.txt
2,226
512
Level>().unwrap().message = "low error"; assert_eq!( err.downcast_ref::<HighLevel>().unwrap().message, "high context", ); assert_eq!( err.downcast_ref::<MidLevel>().unwrap().message, "mid context", ); assert_eq!(err.downcast_ref::<LowLevel>().unwrap().message, "low e...
rust_dataset_chunk_2227
rust_dataset.txt
2,227
512
use std::error::Error as StdError; use std::fmt::{self, Display}; use std::io; #[test] fn test_downcast() { assert_eq!( "oh no!", bail_literal().unwrap_err().downcast::<&str>().unwrap(), ); assert_eq!( "oh no!", bail_fmt().unwrap_err().downcast::<String>().unwrap(), ); ...
rust_dataset_chunk_2228
rust_dataset.txt
2,228
512
!", ref_dyn.to_string()); let ref_dyn_send_sync: &(dyn StdError + Send + Sync) = error.as_ref(); assert_eq!("oh no!", ref_dyn_send_sync.to_string()); } #[test] fn test_large_alignment() { #[repr(align(64))] #[derive(Debug)] struct LargeAlignedError(&'static str); impl Display for LargeAlignedE...
rust_dataset_chunk_2229
rust_dataset.txt
2,229
512
std::iter; use std::marker::{PhantomData, PhantomData as P}; use std::mem; use std::ops::Add; use std::ptr; struct S; impl<T> Add<T> for S { type Output = bool; fn add(self, rhs: T) -> Self::Output { let _ = rhs; false } } trait Trait: Sized { const V: usize = 0; fn t(self, i: i3...
rust_dataset_chunk_2230
rust_dataset.txt
2,230
512
false | false | false | false | false | false | false | false | false | false | false | false | false | false | false | false | false | false | false | false | false )); test().unwrap_err(); } #[test] fn test_low_precedence_control_flow() { #[allow(unreachable_code)] let test = || { ...
rust_dataset_chunk_2231
rust_dataset.txt
2,231
512
"Condition failed: `S + move || 1 == 1`"); let test = || Ok(ensure!(S + || 1 == 1)); assert_err(test, "Condition failed: `S + || 1 == 1`"); // Must not partition as `S + ((move | ()) | 1) == 1` by treating those // pipes as bitwise-or. let test = || Ok(ensure!(S + move |()| 1 == 1)); assert_e...
rust_dataset_chunk_2232
rust_dataset.txt
2,232
512
`if false {}.t(1) == 2` (1 vs 2)"); #[rustfmt::skip] let test = || Ok(ensure!(if false {} else {}.t(1) == 2)); assert_err( test, "Condition failed: `if false {} else {}.t(1) == 2` (1 vs 2)", ); #[rustfmt::skip] let test = || Ok(ensure!(if false {} else if false {}.t(1) == 2));...
rust_dataset_chunk_2233
rust_dataset.txt
2,233
512
rustfmt::skip] let test = || Ok(ensure!(while false {}.t(1) == 2)); assert_err( test, "Condition failed: `while false {}.t(1) == 2` (1 vs 2)", ); #[rustfmt::skip] let test = || Ok(ensure!(while let None = Some(1) {}.t(1) == 2)); assert_err( test, "Condition faile...
rust_dataset_chunk_2234
rust_dataset.txt
2,234
512
|| Ok(ensure!({ let x = 1; x } >= 3)); assert_err(test, "Condition failed: `{ let x = 1; x } >= 3` (1 vs 3)"); let test = || Ok(ensure!(S + async { 1 } == true)); assert_err( test, "Condition failed: `S + async { 1 } == true` (false vs true)", ); let test = || Ok(ensure!(S + async...
rust_dataset_chunk_2235
rust_dataset.txt
2,235
512
(1) == 2` (1 vs 2)", ); let test = || Ok(ensure!(Chain::<'static>::new.t(1) == 2)); assert_err( test, "Condition failed: `Chain::<'static>::new.t(1) == 2` (1 vs 2)", ); #[rustfmt::skip] let test = || Ok(ensure!(Chain::<'static,>::new.t(1) == 2)); assert_err( test, ...
rust_dataset_chunk_2236
rust_dataset.txt
2,236
512
`E::U::<u8,> > E::U` (U vs U)"); let test = || Ok(ensure!(Generic::<dyn Debug + Sync> != Generic)); assert_err( test, "Condition failed: `Generic::<dyn Debug + Sync> != Generic` (Generic vs Generic)", ); let test = || Ok(ensure!(Generic::<dyn Fn() + Sync> != Generic)); assert_err(...
rust_dataset_chunk_2237
rust_dataset.txt
2,237
512
PhantomData<u8>)", ); let result = Ok::<_, Error>(1); let test = || Ok(ensure!(result? == 2)); assert_err(test, "Condition failed: `result? == 2` (1 vs 2)"); let test = || Ok(ensure!((2, 3).1 == 2)); assert_err(test, "Condition failed: `(2, 3).1 == 2` (3 vs 2)"); #[rustfmt::skip] let...
rust_dataset_chunk_2238
rust_dataset.txt
2,238
512
u8 > 1)); assert_err(test, "Condition failed: `'\\0' as u8 > 1` (0 vs 1)"); let test = || Ok(ensure!('\0' as ::std::primitive::u8 > 1)); assert_err( test, "Condition failed: `'\\0' as ::std::primitive::u8 > 1` (0 vs 1)", ); let test = || Ok(ensure!(&[0] as &[i32] == [1])); ass...
rust_dataset_chunk_2239
rust_dataset.txt
2,239
512
vs \"\")", ); let test = || Ok(ensure!(&m as &&'static mut str != &s)); assert_err( test, "Condition failed: `&m as &&'static mut str != &s` (\"\" vs \"\")", ); let f = || {}; let test = || Ok(ensure!(f as fn() as usize * 0 != 0)); assert_err( test, "Condit...
rust_dataset_chunk_2240
rust_dataset.txt
2,240
512
f as fn() -> ! as usize * 0 != 0` (0 vs 0)", ); trait EqDebug<T>: PartialEq<T> + Debug { type Assoc; } impl<S, T> EqDebug<T> for S where S: PartialEq<T> + Debug, { type Assoc = bool; } let test = || Ok(ensure!(&0 as &dyn EqDebug<i32, Assoc = bool> != &0)); ...
rust_dataset_chunk_2241
rust_dataset.txt
2,241
512
=1 = 0 { 0 } else { 1 } == 1` (0 vs 1)", ); let test = || Ok(ensure!(if let &0 = &0 { 0 } else { 1 } == 1)); assert_err( test, "Condition failed: `if let &0 = &0 { 0 } else { 1 } == 1` (0 vs 1)", ); let test = || Ok(ensure!(if let &&0 = &&0 { 0 } else { 1 } == 1)); assert_err( ...
rust_dataset_chunk_2242
rust_dataset.txt
2,242
512
= p { 0 } else { 1 } == 1)); assert_err( test, "Condition failed: `if let P::<u8> {} = p { 0 } else { 1 } == 1` (0 vs 1)", ); let test = || Ok(ensure!(if let ::std::marker::PhantomData = p {} != ())); assert_err( test, "Condition failed: `if let ::std::marker::PhantomDa...
rust_dataset_chunk_2243
rust_dataset.txt
2,243
512
} fn g() -> Result<()> { f().context("f failed") } fn h() -> Result<()> { g().context("g failed") } const EXPECTED_ALTDISPLAY_F: &str = "oh no!"; const EXPECTED_ALTDISPLAY_G: &str = "f failed: oh no!"; const EXPECTED_ALTDISPLAY_H: &str = "g failed: f failed: oh no!"; const EXPECTED_DEBUG_F: &str = "oh no!...
rust_dataset_chunk_2244
rust_dataset.txt
2,244
512
())); } --- FILE: anyhow/tests/test_macros.rs --- #![allow( clippy::assertions_on_result_states, clippy::eq_op, clippy::incompatible_msrv, // https://github.com/rust-lang/rust-clippy/issues/12257 clippy::items_after_statements, clippy::match_single_binding, clippy::needless_pass_by_value, ...
rust_dataset_chunk_2245
rust_dataset.txt
2,245
512
the other side of the await point, making the // enclosing future non-Send. future::ready(anyhow!("...")).await; }); fn message(cell: Cell<&str>) -> &str { cell.get() } require_send_sync(async { future::ready(anyhow!(message(Cell::new("...")))).await; }); } #[test...
rust_dataset_chunk_2246
rust_dataset.txt
2,246
512
let error = anyhow!(msg); assert!(error.source().is_none()); } #[test] fn test_fmt_source() { let error = anyhow!("{} {}!", "oh", "no"); assert!(error.source().is_none()); } #[test] fn test_io_source() { let io = io::Error::new(io::ErrorKind::Other, "oh no!"); let error = anyhow!(TestError::Io...
rust_dataset_chunk_2247
rust_dataset.txt
2,247
512
/no-impl.rs --- use anyhow::anyhow; #[derive(Debug)] struct Error; fn main() { let _ = anyhow!(Error); } --- FILE: anyhow/tests/ui/temporary-value.rs --- use anyhow::anyhow; fn main() { let _ = anyhow!(&String::new()); } --- FILE: anyhow/tests/ui/wrong-interpolation.rs --- use anyhow::{bail, Result}; fn...
rust_dataset_chunk_2248
rust_dataset.txt
2,248
512
[lib] path = "test.rs" [dependencies] anyhow = { path = "../..", default-features = false } [features] default = ["std"] std = ["anyhow/std"] backtrace = ["anyhow/backtrace"] --- FILE: anyhow/LICENSE-APACHE --- Apache License Version 2.0, January 2004 ...
rust_dataset_chunk_2249
rust_dataset.txt
2,249
512
able from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitt...
rust_dataset_chunk_2250
rust_dataset.txt
2,250
512
then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, p...
rust_dataset_chunk_2251
rust_dataset.txt
2,251
512
the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant...
rust_dataset_chunk_2252
rust_dataset.txt
2,252
512
reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS --- FILE: anyhow/LICENSE-MIT --- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
rust_dataset_chunk_2253
rust_dataset.txt
2,253
512
%3Amaster) This library provides [`anyhow::Error`][Error], a trait object based error type for easy idiomatic error handling in Rust applications. [Error]: https://docs.rs/anyhow/1.0/anyhow/struct.Error.html ```toml [dependencies] anyhow = "1.0" ``` <br> ## Details - Use `Result<T, anyhow::Error>`, or equivalentl...
rust_dataset_chunk_2254
rust_dataset.txt
2,254
512
the error if the underlying error type does not already provide its own. In order to see backtraces, they must be enabled through the environment variables described in [`std::backtrace`]: - If you want panics and errors to both have backtraces, set `RUST_BACKTRACE=1`; - If you want only errors to have ...
rust_dataset_chunk_2255
rust_dataset.txt
2,255
512
trait that `?`-based error conversions are defined by is only available in std in those old versions. <br> ## Comparison to failure The `anyhow::Error` type works something like `failure::Error`, but unlike failure ours is built around the standard library's `std::error::Error` trait rather than a separate trait `f...
rust_dataset_chunk_2256
rust_dataset.txt
2,256
512
//! resumed with the usual command. That happens only once a session is chosen (enter or tab in //! the picker, or named by id), in this process, before the command is run or handed to the //! shell widget, so the command the widget puts on the command line works as it stands. //! - `--in <harness>` continues the...
rust_dataset_chunk_2257
rust_dataset.txt
2,257
512
esstools::fork`]), and that is //! resumed. The original is left as it is. A session that went on separately on several //! machines forks from its newest branch. //! - `--branch` picks the branch to catch up to, to switch to, to fork from, or to continue in //! another harness: `this`, `@<host id>`, or the start...
rust_dataset_chunk_2258
rust_dataset.txt
2,258
512
resume_tui::source::{Relation, harness_arg, harness_label}; use crate::resume_tui::{ Outcome, Picker, ResumeContext, ResumePlan, Resumer, SessionRow, SessionSource, startup, }; const ACCEPT_PREFIX: &str = "__atuin_accept__:"; /// Ids shorter than this are treated as search text, so a short word can't resume by ac...
rust_dataset_chunk_2259
rust_dataset.txt
2,259
512
the only one it can be switched to), in place, and resume it: the /// history it shares with that branch is kept as it is, and the branch's messages since are /// appended from sync. The branch it was on stays in atuin, for `--fork` to bring back, and /// the copy as it was is kept as a backup. Only when s...
rust_dataset_chunk_2260
rust_dataset.txt
2,260
512
stdout. Print, /// chdir and exec. Exec, } impl Cmd { /// Whether someone is there to answer a question first: the shell widget, or a terminal /// picker, not a printed command. #[must_use] pub fn is_interactive(&self) -> bool { self.output() != Output::Print } fn output(&...
rust_dataset_chunk_2261
rust_dataset.txt
2,261
512
: Vec<usize> = (0..found.len()) .filter(|&i| { let row = &found[i]; row.handle.session.as_ref() == query || atuin_id == Some(row.atuin_id) }) .collect(); if let [exact] = exact.as_slice() { return Ok(Some(found.swap_remove(*exact))); } let mut found = ...
rust_dataset_chunk_2262
rust_dataset.txt
2,262
512
).len()).max().unwrap_or(0); let mut note = String::new(); for row in found { let when = tz.to_datetime(row.updated_at).display().ymd_hm(); note.push_str(&format!( "\n {:<width$} {when} {} ({})", harness_label(row.handle.harness), title_line(&row.title.tex...
rust_dataset_chunk_2263
rust_dataset.txt
2,263
512
lines: Vec<String> = message.lines().map(|line| line.escape_non_printable().to_string()).collect(); lines.join("\n") } /// With `flag` (`--switch`, `--branch`, `--as-is`) given and `query` naming no single session, the /// error saying to be more specific ([`be_more_specific`]). async fn no_single_session...
rust_dataset_chunk_2264
rust_dataset.txt
2,264
512
let found = source.find_by_id(parent.session.as_ref()).await?; let Some(up) = found.into_iter().find(|r| r.handle == parent) else { bail!( "{} is a subagent, which can't be resumed, and the session it works for ({}) \ isn't in the session database", ...
rust_dataset_chunk_2265
rust_dataset.txt
2,265
512
plan, status) = match cmd.continue_in { Some(into) => continue_plan(source, resumer, query, into, branch, here).await?, None => fork_plan(source, resumer, query, branch, here).await?, }; // The widget reads stderr for the command: nothing else may go there. if output != O...
rust_dataset_chunk_2266
rust_dataset.txt
2,266
512
!( "the picker needs a terminal; to resume without one, name the thread: `atuin threads \ resume <id>` (`atuin threads list` lists them)" ); } let mut themes = ThemeManager::default(); let theme = themes.load_theme(settings.theme.name.as_str()); let (outcome, note) = Pic...
rust_dataset_chunk_2267
rust_dataset.txt
2,267
512
::Switch { return Ok(resumer.switch(source, row, head.as_ref()).await.map(|switched| { let status = switched.status(); (switched.plan, Some(status)) })); } Ok(match resumer.catch_up(source, row, head.as_ref()).await { Ok(CatchUp::Ready { plan, status }) => Ok((pla...
rust_dataset_chunk_2268
rust_dataset.txt
2,268
512
first it can. // Without `--branch`, `--switch` goes to the only branch it can, and refuses to choose // between several. let named = held.branches.get(held.chosen).filter(|b| b.switch && held.chosen != 0); if let Some(branch) = named.or_else(|| held.switches().next()) { let pick = if named.is_...
rust_dataset_chunk_2269
rust_dataset.txt
2,269
512
plan, said) = resumed.map_err(|why| { eyre::eyre!("{}", escaped(&format!("can't resume {}: {why}", row.handle.session))) })?; let mut status = format!("it's a {} session already: resuming it", harness_label(kind)); for said in redirected.into_iter().chain(said) { status.p...
rust_dataset_chunk_2270
rust_dataset.txt
2,270
512
`--fork` forks the thread an id names: no single thread has the id {query:?}"); }; let head = match branch { Some(selector) => Some(pick_head(source, &row, selector, here).await?), None => None, }; let from = catchup::fork_from(source, &row.handle, head.as_ref()).await; let forked = ...
rust_dataset_chunk_2271
rust_dataset.txt
2,271
512
print or \ run it: {}", line.escape_non_printable() ); } Ok(line) } /// Change into the session's directory and replace this process with the harness. fn exec(plan: &ResumePlan) -> Result<()> { // On Windows, spawn the file the resumability check found (`claude.cmd`), whic...
rust_dataset_chunk_2272
rust_dataset.txt
2,272
512
std::process::exit(status.code().unwrap_or(1)); } } #[cfg(test)] mod tests { use clap::Parser; use rstest::rstest; use super::*; use crate::resume_tui::fake::{self, FakeResumer, FakeSource}; #[derive(Parser)] struct Cli { #[command(flatten)] cmd: Cmd, } #[rstest]...
rust_dataset_chunk_2273
rust_dataset.txt
2,273
512
len: usize) { let source = FakeSource::new(); let wanted = source.find_by_id("7f3c9a12").await.unwrap().remove(0); let id = wanted.atuin_id.to_string(); let row = direct_match(&source, &id[..len]).await.unwrap().unwrap(); assert_eq!(row.handle, wanted.handle); } /// An...
rust_dataset_chunk_2274
rust_dataset.txt
2,274
512
ai_session::HarnessKind; use crate::resume_tui::source::Relation; let root = fake::row(HarnessKind::Pi, "01a11e4a-24bd", "the work"); let other = fake::row(HarnessKind::Pi, "01a11e47-485a", "other work"); let mut subagent = fake::row(HarnessKind::Pi, "01a11e4e-af40", "a part of it"); ...
rust_dataset_chunk_2275
rust_dataset.txt
2,275
512
never the picker, which would drop the flag. #[rstest] #[tokio::test] async fn a_flag_on_no_single_session_says_to_be_more_specific() { use atuin_client::ai_session::HarnessKind; let mut claude = fake::row(HarnessKind::ClaudeCode, "7aaabc31-1631", "fix the flaky test"); claude.upda...
rust_dataset_chunk_2276
rust_dataset.txt
2,276
512
.to_string().contains("no thread has the id"), "{err}"); } // Without them, the picker opens on the matches. assert!(no_single_session_for(&source, ambiguous, None).await.is_ok()); } /// A session named that can't be resumed opens the picker on it, but not with `--branch` or /// `--...
rust_dataset_chunk_2277
rust_dataset.txt
2,277
512
source, "ses_4b8e2f1a9c3d7e", true).await.unwrap(); let ids: Vec<_> = matches.iter().map(|r| r.handle.session.as_ref()).collect(); assert!(ids.len() > 1, "{ids:?}"); assert!(ids.iter().all(|id| id.starts_with("ses_4b8e2f1a9c3d7e")), "{ids:?}"); let err = ambiguous_matches(&source, "ses_...
rust_dataset_chunk_2278
rust_dataset.txt
2,278
512
, ) { let source = FakeSource::new(); let (row, note) = direct_target(&source, query).await.unwrap().unwrap(); assert_eq!(row.handle.session.as_ref(), target); assert_eq!(note.is_some(), redirected, "{note:?}"); if let Some(note) = note { assert!(note.starts_with(...
rust_dataset_chunk_2279
rust_dataset.txt
2,279
512
)"), "{note}"); assert!(note.contains(" plan (7aaabc31-1631^[[2J)"), "{note}"); assert!(title_line(&"long ".repeat(40)).chars().count() <= TITLE_WIDTH + 1); } /// A plan whose id or directory carries control characters isn't printed (or handed to the /// widget) as it is; one without them...
rust_dataset_chunk_2280
rust_dataset.txt
2,280
512
.unwrap(); assert_eq!(plan.program, "codex"); assert_eq!(plan.args, ["resume", "continued-7f3c9a12-5be0-4d7e-9c41-0a8e2b6f4d10"]); assert_eq!(status, "continuing in Codex: 42 tool calls become notes"); let err = continue_plan(&source, &resumer, "fix flaky", HarnessA...
rust_dataset_chunk_2281
rust_dataset.txt
2,281
512
" ); } /// `--in` continues a session that went on separately on several machines along the branch /// `--branch` names; without one, it continues nothing, listing the branches to name. #[rstest] #[case::by_host(Some("@00000002"), Ok("d"))] #[case::by_head(Some("y"), Ok("y"))] #[cas...
rust_dataset_chunk_2282
rust_dataset.txt
2,282
512
let row = direct_match(&source, "7f3c9a12").await.unwrap().unwrap(); assert_eq!(plan, resumer.plan(&row).await.unwrap().plan); assert_eq!(status, "it's a Claude Code session already: resuming it"); assert!(resumer.continues.lock().is_empty()); } /// `atuin threads resume <id> --fork` f...
rust_dataset_chunk_2283
rust_dataset.txt
2,283
512
().unwrap(); let rows = fake::synced_rows_of(&row.handle, true); (FakeSource::new().with_synced(&row.handle, rows), row) } /// `atuin threads resume <id>` catches the session's copy here up with sync first, saying what it /// wrote. A choice to make fails, saying why and naming the flags th...
rust_dataset_chunk_2284
rust_dataset.txt
2,284
512
--fork` forks it from this machine's branch; `--branch` \ picks another:\n y this machine · " ); assert!(err.starts_with(&want), "{err}"); assert!(err.contains("\n d @00000002 · "), "{err}"); let got = direct_plan(&source, &held, &row, Direct::AsIs, None, here).await.u...
rust_dataset_chunk_2285
rust_dataset.txt
2,285
512
)] #[case::switch_to_a_branch(&["--switch", "--branch", "@00000002"], true)] #[case::switch_and_fork(&["--switch", "--fork"], false)] #[case::switch_and_in(&["--switch", "--in", "pi"], false)] #[case::switch_and_as_is(&["--switch", "--as-is"], false)] #[case::as_is(&["--as-is", "--print"], true)] ...
rust_dataset_chunk_2286
rust_dataset.txt
2,286
512
umer = FakeResumer::default(); let got = direct_plan(&source, &resumer, &row, Direct::Switch, Some("@00000002"), here) .await .unwrap() .unwrap(); let said = format!( "switched to @00000002's branch: 4 messages (your copy is at {})", fake::SWIT...
rust_dataset_chunk_2287
rust_dataset.txt
2,287
512
!(note.contains(&want), "{note}"); // With a branch named (`--branch`), the switch it offers is to that one, as the fork. held.chosen = 1; let note = choice_note(&row, &held, here); let want = format!(", `atuin threads resume {id} --switch --branch d` switches this copy to");...
rust_dataset_chunk_2288
rust_dataset.txt
2,288
512
`atuin threads`, as it was called before. #[command(subcommand, name = "session", hide = true)] Threads(session::Cmd), /// `atuin threads resume`, as it was called before. #[command(hide = true)] Resume(resume::Cmd), } /// `atuin threads resume` is `atuin ai resume`, so it is set up and run in on...
rust_dataset_chunk_2289
rust_dataset.txt
2,289
512
bash, // zsh, fish, nushell, xonsh, and powershell. println!( "# This command is no longer necessary. If you have it in your shell init file, \ feel free to remove it." ); Ok(()) } Command::Threads(cmd) => session::run(cmd...
rust_dataset_chunk_2290
rust_dataset.txt
2,290
512
_t = Style::Auto)] style: Style, } /// `atuin threads`. #[derive(Subcommand, Debug)] pub enum Cmd { /// List captured threads, newest first. List { #[command(flatten)] output: Output, }, /// Show a thread and its messages. Accepts an id, a harness id or `latest`. Show { ...
rust_dataset_chunk_2291
rust_dataset.txt
2,291
512
's id, as its harness names it. #[arg(long)] session: String, }, /// Pick a captured thread and resume it. Resume(super::resume::Cmd), /// What `atuin threads enable` did before `atuin setup` did it, kept so that the scripts still /// running it say what to run instead. #[comma...
rust_dataset_chunk_2292
rust_dataset.txt
2,292
512
::Amp, HarnessArg::Vibe => Self::Vibe, } } } #[derive(Copy, Clone, Debug, ValueEnum)] enum Style { /// Pretty when writing to a terminal, plain otherwise. Auto, Plain, Pretty, /// A single JSON document. Json, /// Newline-delimited JSON: one object per line. Ndjs...
rust_dataset_chunk_2293
rust_dataset.txt
2,293
512
userio::log::info!("threads-rebuilding"); } let (replayed, pending) = progress; if reported != Some(progress) && pending > 0 { userio::log::info!( "threads-rebuild-progress", replayed = replayed, ...
rust_dataset_chunk_2294
rust_dataset.txt
2,294
512
false } }) } // --- subcommands -------------------------------------------------------------------------------- async fn list(client: &mut AiClient, style: Style) -> Result<()> { let sessions = crate::tools::session::list_sessions(client, None, None).await.map_err(|e| eyre!(e))?; let st...
rust_dataset_chunk_2295
rust_dataset.txt
2,295
512
::Message(&message_json(m)))?; writeln!(out)?; } } _ => { write_session_header(&mut out, &session)?; for m in &messages { write_message_text(&mut out, m)?; } } } Ok(()) } async fn search( client: &mut A...
rust_dataset_chunk_2296
rust_dataset.txt
2,296
512
: &mut AiClient, style: Style) -> Result<()> { let mut stream = client.tail_sessions(None).await?; // The daemon streams session-state deltas (Started/Updated) alongside messages. We fold the // deltas into a metadata cache used for headers but never print them: the human tail is a // message log group...
rust_dataset_chunk_2297
rust_dataset.txt
2,297
512
legible. let Some(summary) = message_summary(&m) else { continue; }; let (role_text, role_ansi) = display_role(&m, &summary); if let Style::Plain = style { writeln!( out, ...
rust_dataset_chunk_2298
rust_dataset.txt
2,298
512
<Recent>> { let mut client = AiClient::from_settings(settings).await?; client.wait_for_sessions(|_| {}).await?; let filter = SessionFilter { roots_only: true, ..SessionFilter::default() }; // Newest first, so only as many as are shown. client .list_sessions(&filter) ...
rust_dataset_chunk_2299
rust_dataset.txt
2,299
512
), Origin::Import).await } .await; let reply = match pushed { Ok(reply) => reply, Err(err) => { failed += 1; userio::log::warn!("threads-import-failed", thread = id.as_str(), error = format!("{err:#}")); ...