text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>nabled: bool, pub group: Option<Vec<String>>, }<|fim_prefix|>// repo: HocVienCongGiao/identity-service path: /identity-app/domain/src/entity/user.rs use uuid::Uuid; pub struct User { pub id: Uui<|fim_middle|>d, pub username: String, pub email: Option<String>, pub phone: Option<String...
code_fim
medium
{ "lang": "rust", "repo": "HocVienCongGiao/identity-service", "path": "/identity-app/domain/src/entity/user.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HocVienCongGiao/identity-service path: /identity-app/domain/src/entity/user.rs use uuid::Uuid; pub struct User { pub id: Uui<|fim_suffix|><String>, pub phone: Option<String>, pub enabled: bool, pub group: Option<Vec<String>>, }<|fim_middle|>d, pub username: String, pub e...
code_fim
easy
{ "lang": "rust", "repo": "HocVienCongGiao/identity-service", "path": "/identity-app/domain/src/entity/user.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // If expected is not an error normalize matches if let Ok(expected) = expected.as_ref() { actual = actual.normalize(NormalizeMatches::new(&self.substitutions, expected)); } (expected, actual) } #[track_caller] pub(crate) fn do_action( &sel...
code_fim
hard
{ "lang": "rust", "repo": "giodamelio/little_boxes", "path": "/vendor/snapbox/src/assert.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: giodamelio/little_boxes path: /vendor/snapbox/src/assert.rs le /// /// # Examples /// /// ```rust,no_run /// let actual = "..."; /// snapbox::Assert::new() /// .action_env("SNAPSHOTS") /// .matches_path(actual, "tests/fixtures/help_output_is_clean.txt"); /// ``` #[derive(Clone, Debug)] p...
code_fim
hard
{ "lang": "rust", "repo": "giodamelio/little_boxes", "path": "/vendor/snapbox/src/assert.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[track_caller] fn verify( &self, mut checks: Vec<Result<(std::path::PathBuf, std::path::PathBuf), crate::path::PathDiff>>, ) { if checks.iter().all(Result::is_ok) { for check in checks { let (_expected_path, _actual_path) = check.unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "giodamelio/little_boxes", "path": "/vendor/snapbox/src/assert.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AldaronLau/NoteScout path: /backend/src/sha256.rs use hmac_sha256::Hash; /// Calculate the sha256 to encrypt the password. pub(crate) fn sha<T: AsRef<[u8]>>(input: T) -> [u8; 32] { Hash::hash(input.as_ref()) } /* pub(crate) fn sha() { // First 32 bits of the fractional parts of the squ...
code_fim
hard
{ "lang": "rust", "repo": "AldaronLau/NoteScout", "path": "/backend/src/sha256.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Compression function main loop: for i from 0 to 63 S1 := (e rightrotate 6) xor (e rightrotate 11) xor (e rightrotate 25) ch := (e and f) xor ((not e) and g) temp1 := h + S1 + ch + k[i] + w[i] S0 := (a rightrotate 2) xor (a rightrotate 13) xor (a rightrotate 22) ...
code_fim
hard
{ "lang": "rust", "repo": "AldaronLau/NoteScout", "path": "/backend/src/sha256.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.drawer.event(event.event, event.states, position_info); match event.event { Event::RedrawRequested(_) => { let new_size = self.drawer.update_render_size(self.layout.size.into()); if new_size != self.current_render_buffer_size { self.content = None; } ...
code_fim
hard
{ "lang": "rust", "repo": "mikialex/rendiation", "path": "/interphaser/src/components/canvas.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} impl GPUCanvas { fn event(&mut self, event: &mut EventCtx) { let position_info = CanvasWindowPositionInfo { absolute_position: self.layout.absolute_position, size: self.layout.size, }; self.drawer.event(event.event, event.states, position_info); match event.event { ...
code_fim
hard
{ "lang": "rust", "repo": "mikialex/rendiation", "path": "/interphaser/src/components/canvas.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mikialex/rendiation path: /interphaser/src/components/canvas.rs use std::sync::Arc; use rendiation_texture::Size; use webgpu::{map_size_gpu, GPU2DTextureView, GPUTexture, GPU}; use winit::event::Event; use crate::*; pub struct GPUCanvas { current_render_buffer_size: Size, content: Option<...
code_fim
hard
{ "lang": "rust", "repo": "mikialex/rendiation", "path": "/interphaser/src/components/canvas.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s = "cbaebabacd".to_string(); let p = "abc".to_string(); assert_eq!(Solution::find_anagrams(s, p), vec![0, 6]); let s = "abab".to_string(); let p = "ab".to_string(); assert_eq!(Solution::find_anagrams(s, p), vec![0, 1, 2]); }<|fim_prefix|>// repo: Orca-bit/DataStructureAndAlgor...
code_fim
medium
{ "lang": "rust", "repo": "Orca-bit/DataStructureAndAlgorithm", "path": "/src/slide_window/_438_find_all_anagrams_in_a_string.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Orca-bit/DataStructureAndAlgorithm path: /src/slide_window/_438_find_all_anagrams_in_a_string.rs struct Solution; impl Solution { pub fn find_anagrams(s: String, p: String) -> Vec<i32> { let mut res = vec![]; if s.len() < p.len() { return res; } l...
code_fim
medium
{ "lang": "rust", "repo": "Orca-bit/DataStructureAndAlgorithm", "path": "/src/slide_window/_438_find_all_anagrams_in_a_string.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn update_prefab_async( &self, handle: PrefabHandle, prefab: Prefab, ) -> Result<Option<Prefab>> { prefab.validate()?; if let Some(v) = self.prefabs.write().unwrap().get_mut(handle) { *v = AsyncState::Ok(Arc::new(prefab)); ...
code_fim
hard
{ "lang": "rust", "repo": "kevinw/crayon", "path": "/modules/3d/src/assets/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kevinw/crayon path: /modules/3d/src/assets/mod.rs pub mod prefab; pub use self::prefab::{Prefab, PrefabHandle}; pub mod prefab_loader; pub use self::prefab_loader::PrefabLoader; use std::sync::{Arc, RwLock}; use crayon::application::Engine; use crayon::errors::*; use crayon::utils::object_poo...
code_fim
hard
{ "lang": "rust", "repo": "kevinw/crayon", "path": "/modules/3d/src/assets/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/itertools/src/tuple_impl.rs use std : : iter : : Fuse ; use std : : iter : : FusedIterator ; use std : : iter : : Take ; use std : : iter : : Cycle ; use std : : marker : : PhantomData ; pub trait HomogeneousTuple : TupleCo...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/itertools/src/tuple_impl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>t_ident { ( ) = > { 0 } ; ( i0 : ident ( i : ident ) * ) = > { 1 + count_ident ! ( ( i ) * ) } ; } macro_rules ! rev_for_each_ident { ( m : ident ) = > { } ; ( m : ident i0 : ident ( i : ident ) * ) = > { rev_for_each_ident ! ( m ( i ) * ) ; m ! ( i0 ) ; } ; } macro_rules ! impl_tuple_collect { ( dummy : ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/itertools/src/tuple_impl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simonsan/OxidizeBot path: /bot/src/sys/windows/window.rs ive(Clone)] struct WindowInfo { pub hwnd: HWND, pub hinstance: HINSTANCE, pub hmenu: HMENU, } unsafe impl Send for WindowInfo {} unsafe impl Sync for WindowInfo {} #[derive(Debug)] pub enum Event { /// A meny item was cli...
code_fim
hard
{ "lang": "rust", "repo": "simonsan/OxidizeBot", "path": "/bot/src/sys/windows/window.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let result = unsafe { winuser::InsertMenuItemW(self.info.hmenu, item_idx, 1, &item as *const MENUITEMINFOW) }; if result == FALSE { return Err(io::Error::last_os_error()); } Ok(()) } /// Send a notification. pub fn send_notific...
code_fim
hard
{ "lang": "rust", "repo": "simonsan/OxidizeBot", "path": "/bot/src/sys/windows/window.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simonsan/OxidizeBot path: /bot/src/sys/windows/window.rs owInfo {} #[derive(Debug)] pub enum Event { /// A meny item was clicked. MenuClicked(u32), /// Shutdown was requested. Shutdown, /// Balloon was clicked. BalloonClicked, /// Balloon timed out. BalloonTimeou...
code_fim
hard
{ "lang": "rust", "repo": "simonsan/OxidizeBot", "path": "/bot/src/sys/windows/window.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kumassy/qiita-rust-future path: /std-future/src/main.rs use std::future::{Future}; use std::pin::Pin; use std::task::{Context}; extern crate futures; use futures::{Poll, TryFutureExt}; use futures::executor::{block_on, ThreadPool}; extern crate rand; use rand::Rng; struct MyFuture; impl Futur...
code_fim
hard
{ "lang": "rust", "repo": "Kumassy/qiita-rust-future", "path": "/std-future/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let future = (MyFuture{}).map_ok(|res| { println!("{}", res); }).map_err(|err| { println!("{}", err); }); let _ = block_on(future); let future = get_future(); ThreadPool::new().expect("Failed to create threadpool").run(future); let future = (MyFuture{}).inspe...
code_fim
hard
{ "lang": "rust", "repo": "Kumassy/qiita-rust-future", "path": "/std-future/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if du0du1 > 0. && du0du2 > 0. { // same sign on all of them + not equal 0? return false; // no intersection occurs } // compute plane of triangle (u0,u1,u2) sub!(e1, u1, u0); sub!(e2, u2, u0); cross!(n2, e1, e2); d2 = -dot!(n2, u0); // plane equation 2: n2....
code_fim
hard
{ "lang": "rust", "repo": "catenda/intersection-wasm", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> tmp = d * xxyy; isect2[0] = tmp + e * xx * y1; isect2[1] = tmp + f * xx * y0; if isect1[0] > isect1[1] { isect1.swap(0, 1); } if isect2[0] > isect2[1] { isect2.swap(0, 1); } if isect1[1] < isect2[0] || isect2[1] < isect1[0] { return false; } ...
code_fim
hard
{ "lang": "rust", "repo": "catenda/intersection-wasm", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: catenda/intersection-wasm path: /src/lib.rs #![no_std] #![allow(clippy::many_single_char_names)] #[macro_use] mod macros; mod utils; use wasm_bindgen::prelude::*; #[allow(clippy::cognitive_complexity)] fn coplanar_tri_tri( n: [f32; 3], v0: &[f32], v1: &[f32], v2: &[f32], u...
code_fim
hard
{ "lang": "rust", "repo": "catenda/intersection-wasm", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oneshadab/trebek path: /src/types/dict.rs use std::collections::HashMap; use crate::{misc::RuntimeResult, runtime::Runtime}; <|fim_suffix|> if args.len() != 1 { return Err(format!("'dict-get' called with incorrect number of args")); } let obj = &args[0]; ...
code_fim
hard
{ "lang": "rust", "repo": "oneshadab/trebek", "path": "/src/types/dict.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match key { TObject::Symbol(key) => { let val = self.get(&key).unwrap_or(&TObject::Empty); Ok(val.clone()) }, _ => Err(format!("'dict-get' called with incorrect number of args")), } } }<|fim_prefix|>// repo: oneshadab/...
code_fim
hard
{ "lang": "rust", "repo": "oneshadab/trebek", "path": "/src/types/dict.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let obj = &args[0]; let key = ctx.eval(obj)?; match key { TObject::Symbol(key) => { let val = self.get(&key).unwrap_or(&TObject::Empty); Ok(val.clone()) }, _ => Err(format!("'dict-get' called with incorrect number...
code_fim
hard
{ "lang": "rust", "repo": "oneshadab/trebek", "path": "/src/types/dict.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // using std library hashmap implementations pub fn bday_candles_hashmap(_: i32, height_string: &String) { let mut heights: Vec<i32> = vec![]; let mut height_map: HashMap<i32, i32> = HashMap::new(); let mut max: i32 = -1; for height in height_string.trim().split...
code_fim
hard
{ "lang": "rust", "repo": "sidmishraw/some_rusty_for_ya", "path": "/src/problems.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sidmishraw/some_rusty_for_ya path: /src/problems.rs pub mod problem1 { use std::collections::HashMap; /// bday candle warmup problem pub fn bday_candles(n: i32, height_string: &String) -> i32 { println!("n = {}", &n); // n = number of candles // height_str...
code_fim
hard
{ "lang": "rust", "repo": "sidmishraw/some_rusty_for_ya", "path": "/src/problems.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> max = height; } (&mut heights).push(height); } for height in &heights { if !*(&mut height_map.contains_key(height)) { height_map.insert(*height, 1); } else { let prev_value = match height_m...
code_fim
hard
{ "lang": "rust", "repo": "sidmishraw/some_rusty_for_ya", "path": "/src/problems.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> break 'outer; } if max_prime_in_candicate % prime[i] == 0 { break 'inner; } } max_prime_in_candicate = max_prime_in_candicate + 2; } ...
code_fim
hard
{ "lang": "rust", "repo": "zxk7516/exercise", "path": "/rust/prime-factors/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zxk7516/exercise path: /rust/prime-factors/src/lib.rs pub fn factors(n: u64) -> Vec<u64> { let mut results:Vec<u64> = Vec::new(); let mut computed = n; let mut prime:Vec<u64> = vec![2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]; let mut cur_prime = prime[0]; let mut cur_prime_in...
code_fim
hard
{ "lang": "rust", "repo": "zxk7516/exercise", "path": "/rust/prime-factors/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sqrt_max_prime_in_candicate = (max_prime_in_candicate as f64).sqrt() as u64; 'inner: for i in 0..prime.len(){ if prime[i] > sqrt_max_prime_in_candicate { prime.push(max_prime_in_candicate); max_prime_in_candicate = ma...
code_fim
hard
{ "lang": "rust", "repo": "zxk7516/exercise", "path": "/rust/prime-factors/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("mi numero es {} {}", number, number2); // string format generic println!("mi numero es {1} {0}", number3, number4); //string format with index println!("mi numero es {number5}", number5=number5); //assign alias in string formart }<|fim_prefix|>// repo: Mteheran/rust-guide path: /rus...
code_fim
hard
{ "lang": "rust", "repo": "Mteheran/rust-guide", "path": "/rust-basic/2-variables.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mteheran/rust-guide path: /rust-basic/2-variables.rs fn main() { //implicit type annotation let number : u8; //no negatives values let number2: i8; //Including negative values <|fim_suffix|> // set 2 variables at the same time // the variables are inmutable in this way ...
code_fim
medium
{ "lang": "rust", "repo": "Mteheran/rust-guide", "path": "/rust-basic/2-variables.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prk3/iced-secret-santa path: /src/clip.rs use std::error::Error; use clipboard::*; use std::sync::{Arc, Mutex}; use lazy_static::*; pub use clipboard::ClipboardContext; lazy_static! { static ref CLIP: Arc<Mutex<ClipboardContext>> = Arc::new(Mutex::new(ClipboardProvider::new().unwrap())); }...
code_fim
medium
{ "lang": "rust", "repo": "prk3/iced-secret-santa", "path": "/src/clip.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn write(value: String) -> Result<(), Box<dyn Error>> { let clip_arc = CLIP.clone(); let mut clip = clip_arc.lock().unwrap(); clip.set_contents(value) }<|fim_prefix|>// repo: prk3/iced-secret-santa path: /src/clip.rs use std::error::Error; use clipboard::*; use std::sync::{Arc, Mutex}; us...
code_fim
medium
{ "lang": "rust", "repo": "prk3/iced-secret-santa", "path": "/src/clip.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[async_trait] impl<Req: AppData> RaftNetwork<Req> for TonicNetworkProvider<Req> { #[tracing::instrument(level = "trace", skip(self, rpc))] async fn append_entries(&self, target: u64, rpc: AppendEntriesRequest<Req>) -> Result<AppendEntriesResponse> { let chan = self.get_peer_channel(&targe...
code_fim
hard
{ "lang": "rust", "repo": "ives9638/hadron", "path": "/hadrond/_src/raft/network.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[tracing::instrument(level = "trace", skip(self, rpc))] async fn install_snapshot(&self, target: u64, rpc: InstallSnapshotRequest) -> Result<InstallSnapshotResponse> { let chan = self.get_peer_channel(&target)?; let payload = utils::encode_flexbuf(&rpc).context(utils::ERR_ENCODE_R...
code_fim
hard
{ "lang": "rust", "repo": "ives9638/hadron", "path": "/hadrond/_src/raft/network.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ives9638/hadron path: /hadrond/_src/raft/network.rs use std::collections::HashMap; use std::sync::Arc; use anyhow::{anyhow, Context, Result}; use async_raft::async_trait::async_trait; use async_raft::raft::{AppendEntriesRequest, AppendEntriesResponse, InstallSnapshotRequest, InstallSnapshotResp...
code_fim
hard
{ "lang": "rust", "repo": "ives9638/hadron", "path": "/hadrond/_src/raft/network.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Solverj/person-svc-rust path: /src/models.rs use serde::{Deserialize, Serialize}; use tokio_pg_mapper_derive::PostgresMapper; <|fim_suffix|>#[derive(Deserialize)] pub struct CreatePerson { pub name: String, pub phone: i32, pub address: String }<|fim_middle|>#[derive(Serialize, Deser...
code_fim
medium
{ "lang": "rust", "repo": "Solverj/person-svc-rust", "path": "/src/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize)] pub struct CreatePerson { pub name: String, pub phone: i32, pub address: String }<|fim_prefix|>// repo: Solverj/person-svc-rust path: /src/models.rs use serde::{Deserialize, Serialize}; use tokio_pg_mapper_derive::PostgresMapper; <|fim_middle|>#[derive(Serialize, Deser...
code_fim
medium
{ "lang": "rust", "repo": "Solverj/person-svc-rust", "path": "/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SonicZentropy/tuix path: /core/src/widgets/spinner.rs #![allow(dead_code)] const ICON_LEFT_OPEN_BIG: &str = "\u{e761}"; const ICON_RIGHT_OPEN_BIG: &str = "\u{e762}"; const ICON_DOWN_OPEN_MINI: &str = "\u{e760}"; const ICON_UP_OPEN_MINI: &str = "\u{e763}"; use crate::entity::Entity; use crate:...
code_fim
hard
{ "lang": "rust", "repo": "SonicZentropy/tuix", "path": "/core/src/widgets/spinner.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> state.insert_event( Event::new(WindowEvent::Restyle).target(Entity::new(0, 0)), ); } } _ => {} } } */ if let Some(window_event) = event.mess...
code_fim
hard
{ "lang": "rust", "repo": "SonicZentropy/tuix", "path": "/core/src/widgets/spinner.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xxscloud5722/socketx path: /src/server/tool.rs use std::collections::HashMap; use actix_web::{HttpRequest, web, HttpResponse, ResponseError, Responder}; use actix_web::web::{Payload, BytesMut, Bytes}; use futures_core::stream::Stream; use serde::{Deserialize, Serialize}; use std::collections::ha...
code_fim
hard
{ "lang": "rust", "repo": "xxscloud5722/socketx", "path": "/src/server/tool.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>async fn read_body(mut payload: Payload) -> Result<Bytes, AError> { Ok(match payload.next().await { None => { return Err(AError::parameter("读取内容失败")); } Some(value) => { match value { Ok(value) => { value } Err(_) => { ...
code_fim
hard
{ "lang": "rust", "repo": "xxscloud5722/socketx", "path": "/src/server/tool.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: winksaville/fuchsia path: /third_party/rust_crates/vendor/miow/src/net.rs // /// To safely use this function callers must ensure that these two input /// pointers are valid until the I/O operation is completed, typically via /// completion ports and waiting to receive the completion ...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/miow/src/net.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> const SO_UPDATE_ACCEPT_CONTEXT: c_int = 0x700B; let me = self.as_raw_socket(); let result = unsafe { setsockopt(socket.as_raw_socket(), SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, &me as *const _ as *const _...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/miow/src/net.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> t!(t.join()); }) } #[test] fn udp_send() { each_ip(&mut |addr| { let a = t!(UdpSocket::bind(addr)); let b = t!(UdpSocket::bind(addr)); let a_addr = t!(a.local_addr()); let b_addr = t!(b.local_addr()); asse...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/miow/src/net.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Clears the COMPARE event flag for the specified CC register. pub fn clear_compare_event(&mut self, register: RtcCc) { let event_reg = &self.rtc.events_compare[register as usize]; event_reg.reset(); } /// Checks and clears the COMPARE event flag for the specified CC reg...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf51-hal", "path": "/src/lo_res_timer.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf51-hal path: /src/lo_res_timer.rs cy of a RTC peripheral, in hertz. /// /// This is the highest available frequency. pub const LFCLK_HZ: u32 = 32_768; /// One of the nRF51's low-resolution timers (`nrf51::RTC0` or `nrf51::RTC1`). pub trait Nrf51Rtc: Deref<Target = nrf51::rtc0::Registe...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf51-hal", "path": "/src/lo_res_timer.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf51-hal path: /src/lo_res_timer.rs erals. //! //! This module provides a interface to the RTC peripherals, more or less //! directly corresponding to the underlying registers, tasks, and events. //! //! Note that in order for the RTCs to run, you must also start the //! low-frequency cl...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf51-hal", "path": "/src/lo_res_timer.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> trees } fn main() { let map = Map::load("map.txt").unwrap(); let slopes = vec![(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)]; let result = slopes .iter() .map(|&slope| { let trees = count_trees(&map, slope); println!( "Slope ({}, {}): {} ...
code_fim
hard
{ "lang": "rust", "repo": "kessl/advent_of_code_2020", "path": "/day_3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut trees = 0; let (x, y) = slope; let mut step = 0; loop { match map.at(step * x as usize, step * y as usize) { Ok('#') => trees += 1, Ok(_) => (), Err(_) => break, } step += 1; } trees } fn main() { let map = ...
code_fim
medium
{ "lang": "rust", "repo": "kessl/advent_of_code_2020", "path": "/day_3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kessl/advent_of_code_2020 path: /day_3/src/main.rs #[derive(Debug)] struct Map { map: Vec<Vec<char>>, width: usize, height: usize, } impl Map { fn load(filename: &str) -> Result<Self, &'static str> { let file = std::fs::read_to_string(filename).map_err(|_| "Failed to ope...
code_fim
hard
{ "lang": "rust", "repo": "kessl/advent_of_code_2020", "path": "/day_3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for line in input { let s = line.unwrap(); let v: Vec<u32> = s.split(char::is_whitespace) .filter_map(|subs| match subs.parse() { Ok(n) => Some(n), Err(_) => None, }) .collect(); if is_valid_triangle(v[0], v[...
code_fim
medium
{ "lang": "rust", "repo": "grebnetiew/aoc2016", "path": "/03/puzzle03a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if is_valid_triangle(v[0], v[1], v[2]) { n_possible += 1; } } println!("{}", n_possible); } fn is_valid_triangle(a: u32, b: u32, c: u32) -> bool { a + b > c && b + c > a && c + a > b }<|fim_prefix|>// repo: grebnetiew/aoc2016 path: /03/puzzle03a.rs use std::io; u...
code_fim
hard
{ "lang": "rust", "repo": "grebnetiew/aoc2016", "path": "/03/puzzle03a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: grebnetiew/aoc2016 path: /03/puzzle03a.rs use std::io; use std::io::BufRead; fn main() { let stdin = io::stdin(); let input = stdin.lock().lines(); // iterator of Result<String> // Part A. Triangles by line let mut n_possible = 0; <|fim_suffix|> let v: Vec<u32> = s.spl...
code_fim
medium
{ "lang": "rust", "repo": "grebnetiew/aoc2016", "path": "/03/puzzle03a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mmstick/jsonapi-rust path: /tests/api_test.rs "); let serialized = serde_json::to_string(&resource).unwrap(); let deserialized: Resource = serde_json::from_str(&serialized).unwrap(); assert_eq!(deserialized.id, resource.id); let jsonapidocument = JsonApiDocument { data...
code_fim
hard
{ "lang": "rust", "repo": "mmstick/jsonapi-rust", "path": "/tests/api_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let _ = env_logger::try_init(); let s = ::read_json_file("data/resource_001.json"); let data: Result<Resource, serde_json::Error> = serde_json::from_str(&s); assert!(data.is_ok()); } #[test] fn can_deserialize_jsonapi_example_resource_002() { let _ = env_logger::try_init(); let s ...
code_fim
hard
{ "lang": "rust", "repo": "mmstick/jsonapi-rust", "path": "/tests/api_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn can_deserialize_jsonapi_example_resource_001() { let _ = env_logger::try_init(); let s = ::read_json_file("data/resource_001.json"); let data: Result<Resource, serde_json::Error> = serde_json::from_str(&s); assert!(data.is_ok()); } #[test] fn can_deserialize_jsonapi_example_res...
code_fim
hard
{ "lang": "rust", "repo": "mmstick/jsonapi-rust", "path": "/tests/api_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (y - y1) * (y - y1)).sqrt(); let ans = z1.atan2(d) * 360_f64 / 2_f64 / std::f64::consts::PI; println!("{}", ans); } }<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/typical90/src/bin/018.rs use proconio::input; fn main() { input! { t: f64, ...
code_fim
medium
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/typical90/src/bin/018.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/typical90/src/bin/018.rs use proconio::input; fn main() { input! { t: f64, l: f64, x: f64, y: f64, q: usize, <|fim_suffix|> (y - y1) * (y - y1)).sqrt(); let ans = z1.atan2(d) * 360_f64...
code_fim
hard
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/typical90/src/bin/018.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> quote! { impl #impl_generics reclutch::WidgetChildren for #name #ty_generics #where_clause { fn children(&self) -> Vec<&dyn Widget> { vec![ #(#children),* ] } fn children_mut(&mut self) -> Vec<&mut dyn Widget> { ...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/reclutch", "path": "/derive/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lineCode/reclutch path: /derive/src/lib.rs extern crate proc_macro; use {proc_macro::TokenStream, quote::quote}; #[proc_macro_derive(WidgetChildren, attributes(widget_child))] pub fn widget_macro_derive(input: TokenStream) -> TokenStream { let ast = syn::parse(input).unwrap(); impl_wi...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/reclutch", "path": "/derive/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn impl_widget_macro(ast: &syn::DeriveInput) -> TokenStream { enum StringOrInt { String(String), Int(usize), } let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl(); let name = &ast.ident; let mut children = Vec::new(); if let syn::Data::S...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/reclutch", "path": "/derive/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tls_config = if config.enable_control_plane_tls { info!("control plane tls enabled"); Some(SERVER_CONFIG.get().1.server_tls_config()) } else { None }; let mut builder = HttpServer::new(move || { let mut service = web::scope("/api") .wrap_fn(...
code_fim
hard
{ "lang": "rust", "repo": "zhaoshiling1017/keyhouse", "path": "/src/control/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> builder = if let Some(tls_config) = tls_config { builder.bind_rustls(SERVER_CONFIG.get().0.control_plane_ip.clone(), tls_config) } else { builder.bind(SERVER_CONFIG.get().0.control_plane_ip.clone()) } .expect("failed to bind control plane"); info!( "starting co...
code_fim
hard
{ "lang": "rust", "repo": "zhaoshiling1017/keyhouse", "path": "/src/control/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhaoshiling1017/keyhouse path: /src/control/mod.rs use crate::prelude::*; use crate::server_suite::config::SERVER_CONFIG; use crate::store::OwnedStore; use crate::Metric; use actix_service::Service; use actix_web::{ dev::{Body, ServiceRequest, ServiceResponse}, http::Method, web, ...
code_fim
hard
{ "lang": "rust", "repo": "zhaoshiling1017/keyhouse", "path": "/src/control/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn next_pos(&mut self) -> usize { match self.dir { Dir::CW => { if self.pos == self.pins.len() - 1 { 0 } else { self.pos + 1 } } Dir::CCW => { ...
code_fim
hard
{ "lang": "rust", "repo": "aq1018/rpizw-test", "path": "/src/devices/stepper_motor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aq1018/rpizw-test path: /src/devices/stepper_motor.rs use embedded_hal::digital::v2::OutputPin; use std::{thread::sleep, time::Duration}; #[derive(Copy, Clone, PartialEq)] pub enum Dir { CCW, CW, } pub struct StepperMotor<'a, PIN, E> where PIN: OutputPin<Error = E>, { pins: &'a...
code_fim
hard
{ "lang": "rust", "repo": "aq1018/rpizw-test", "path": "/src/devices/stepper_motor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hallcristobal/twitchchat-rust path: /src/lib/chat_connection.rs use chat::Result; use std::fmt::Display; use std::io::{BufRead, BufReader, Write}; use std::io::{Error, ErrorKind}; use std::net; const TWITCH_SERVER: &'static str = "irc.chat.twitch.tv:6667"; pub struct ChatConnection { strea...
code_fim
hard
{ "lang": "rust", "repo": "hallcristobal/twitchchat-rust", "path": "/src/lib/chat_connection.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn raw_message(&mut self) -> Result<String> { let mut buf = String::new(); match self.reader.read_line(&mut buf) { Ok(0) => Err(Error::from(ErrorKind::NotConnected).into()), Err(e) => Err(e.into()), _ => Ok(buf), } } pub fn send_...
code_fim
hard
{ "lang": "rust", "repo": "hallcristobal/twitchchat-rust", "path": "/src/lib/chat_connection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn request_tags(&mut self) -> Result<()> { self.send_raw("CAP REQ :twitch.tv/tags")?; Ok(()) } pub fn request_commands(&mut self) -> Result<()> { self.send_raw("CAP REQ :twitch.tv/commands")?; Ok(()) } pub fn raw_message(&mut self) -> Result<String...
code_fim
hard
{ "lang": "rust", "repo": "hallcristobal/twitchchat-rust", "path": "/src/lib/chat_connection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.sender_seq = 1; self.target_seq = 1; } fn overwrite_seqs(&mut self, sender: i32, target: i32) { self.sender_seq = sender; self.target_seq = target; } } pub trait MessageStore { fn init(&mut self, sender: Sender); fn sent(&mut self, frame: &FixFra...
code_fim
hard
{ "lang": "rust", "repo": "robertdigital/fix-rust", "path": "/fixclient/src/connector/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.get_state().target_seq } fn overwrite_target_seq(&mut self, new_seq: i32) -> io::Result<()>; fn overwrite_sender_seq(&mut self, new_seq: i32) -> io::Result<()>; } pub trait SessionState { fn init(&mut self, sender: Sender); fn build_frame(&mut self, message: FixMessage,...
code_fim
hard
{ "lang": "rust", "repo": "robertdigital/fix-rust", "path": "/fixclient/src/connector/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robertdigital/fix-rust path: /fixclient/src/connector/mod.rs ///! This module attempts to implement the common fix handler, /// and just calls the user code through the [UserHandler] which /// is somewhat similar to the way the quickfix engine is designed. use std::{io}; use fix::fixmessage...
code_fim
hard
{ "lang": "rust", "repo": "robertdigital/fix-rust", "path": "/fixclient/src/connector/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn is_global(&self) -> bool { self.get_guild().is_none() } } impl LangStat { pub fn get_id(&self) -> i32 { self.id } pub fn get_lang_name(&self) -> &str { &self.lang_name } pub fn get_snippets_executed(&self) -> i32 { self.snippets_execute...
code_fim
hard
{ "lang": "rust", "repo": "Kryod/rustacean", "path": "/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let db = db.get().unwrap(); let epoch = match std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH) { Ok(n) => n.as_secs(), Err(_) => return, }; let _ = diesel::delete(ban) .filter(end_epoch.is_not_null() ...
code_fim
hard
{ "lang": "rust", "repo": "Kryod/rustacean", "path": "/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kryod/rustacean path: /src/models.rs use std::collections::HashMap; use std::collections::hash_map::Entry::{ Occupied, Vacant }; use chrono::prelude::NaiveDateTime; use serenity::model::prelude::{ UserId, GuildId }; use diesel::prelude::*; use crate::{ schema, DbPoolType }; #[derive(Queryable...
code_fim
hard
{ "lang": "rust", "repo": "Kryod/rustacean", "path": "/src/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> req.extensions.insert::<ResponseTimeLoggerMiddleware>(precise_time_ns()); Ok(()) } } impl AfterMiddleware for ResponseTimeLoggerMiddleware { fn after(&self, req: &mut Request, res: Response) -> IronResult<Response> { let delta = precise_time_ns() - *req.extensions.get::<Re...
code_fim
hard
{ "lang": "rust", "repo": "Arekkusuva/iron-sample", "path": "/src/api/middlewares/response_time_logger.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Arekkusuva/iron-sample path: /src/api/middlewares/response_time_logger.rs use iron::prelude::*; use iron::{status, typemap, BeforeMiddleware, AfterMiddleware}; use time::precise_time_ns; use api::middlewares::logger::LoggerReqExt; pub struct ResponseTimeLoggerMiddleware; impl typemap::Key for...
code_fim
medium
{ "lang": "rust", "repo": "Arekkusuva/iron-sample", "path": "/src/api/middlewares/response_time_logger.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct ResponseTimeLoggerMiddleware; impl typemap::Key for ResponseTimeLoggerMiddleware { type Value = u64; } impl BeforeMiddleware for ResponseTimeLoggerMiddleware { fn before(&self, req: &mut Request) -> IronResult<()> { req.extensions.insert::<ResponseTimeLoggerMiddleware>(precise_tim...
code_fim
medium
{ "lang": "rust", "repo": "Arekkusuva/iron-sample", "path": "/src/api/middlewares/response_time_logger.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn add_rss_source_resolver(pool: Pool<PostgresConnectionManager>, xml_url: &str) -> Result<Source> { Url::parse(xml_url)?; let pg = PgDatabase::from_pool(pool)?; let maybe_feed = fetch_feeds_channel(xml_url)?; let feed = maybe_feed.ok_or_else(|| ErrorKind::NotFound)?; let source_ti...
code_fim
medium
{ "lang": "rust", "repo": "Wadjetz/mindstream-poc", "path": "/src/sources_resolvers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wadjetz/mindstream-poc path: /src/sources_resolvers.rs use url::Url; use r2d2::Pool; use r2d2_postgres::PostgresConnectionManager; use pg::PgDatabase; <|fim_suffix|>pub fn add_rss_source_resolver(pool: Pool<PostgresConnectionManager>, xml_url: &str) -> Result<Source> { Url::parse(xml_url)?;...
code_fim
medium
{ "lang": "rust", "repo": "Wadjetz/mindstream-poc", "path": "/src/sources_resolvers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let code = match self { Ok(v) => return Ok(v), Err(TargetError::Fatal(e)) => return Err(GdbStubError::TargetError(e)), // Recoverable errors: // Error code 121 corresponds to `EREMOTEIO` lol Err(TargetError::NonFatal) => 121, ...
code_fim
medium
{ "lang": "rust", "repo": "mchesser/gdbstub", "path": "/src/gdbstub_impl/target_result_ext.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mchesser/gdbstub path: /src/gdbstub_impl/target_result_ext.rs use crate::target::TargetError; use crate::GdbStubError; /// Extension trait to ease working with `TargetResult` in the GdbStub /// implementation. pub(super) trait TargetResultExt<V, T, C> { /// Encapsulates the boilerplate asso...
code_fim
medium
{ "lang": "rust", "repo": "mchesser/gdbstub", "path": "/src/gdbstub_impl/target_result_ext.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn json_deploy_template_missing_ctors() { let json = json!({ "svm_version": 1, "code_version": 2, "name": "My Template", "desc": "A few words", "code": "C0DE", "data": "0000000100000003", }) .to...
code_fim
hard
{ "lang": "rust", "repo": "sudachen/svm", "path": "/crates/codec/src/api/json/deploy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sudachen/svm path: /crates/codec/src/api/json/deploy.rs use serde::{Deserialize, Serialize}; use svm_layout::{FixedLayoutBuilder, Id, Layout}; use svm_types::{CodeSection, CtorsSection, DataSection, HeaderSection}; use super::{serde_types::HexBlob, JsonError, JsonSerdeUtils}; use crate::api::b...
code_fim
hard
{ "lang": "rust", "repo": "sudachen/svm", "path": "/crates/codec/src/api/json/deploy.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Note: `LayoutBuilder` assume that the `first var id` is zero let mut builder = FixedLayoutBuilder::with_capacity(data.len()); builder.set_first(Id(0)); builder.extend_from_slice(&data); let fixed = builder.build(); let layout = Layout::Fixed(fixed); Ok(layout) } #[derive...
code_fim
hard
{ "lang": "rust", "repo": "sudachen/svm", "path": "/crates/codec/src/api/json/deploy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> env::args().collect::<Vec<String>>().into_iter().nth(1) } fn load_input(file: String) -> String { use std::fs; fs::read_to_string(file).expect("Unable to read file") } // This sort of works but to finish you // have to do CTRL-C (which actually types the escape code) and then // press enter ...
code_fim
medium
{ "lang": "rust", "repo": "Thermatix/a_coding_test_wot_I_did", "path": "/src/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Thermatix/a_coding_test_wot_I_did path: /src/input.rs pub fn get_commands() -> String { match check_for_file_name() { Some(file) => load_input(file), None => accept_user_input(), } } <|fim_suffix|> while running.load(Ordering::SeqCst) { stdin().read_line(&mut ...
code_fim
hard
{ "lang": "rust", "repo": "Thermatix/a_coding_test_wot_I_did", "path": "/src/input.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// This sort of works but to finish you // have to do CTRL-C (which actually types the escape code) and then // press enter to finish, this is becuase stdin().read_line() locks // the input and without using an external crate I'm not sure how to // make this work as intended fn accept_user_input() -> Stri...
code_fim
medium
{ "lang": "rust", "repo": "Thermatix/a_coding_test_wot_I_did", "path": "/src/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ryan-Git/learn-rust path: /src/ch7_modules.rs //see project communicator //Rules of Module Filesystems // //Let’s summarize the rules of modules with regard to files: // //If a module named foo has no submodules, you should put the declarations for foo in a file named foo.rs. //If a module name...
code_fim
hard
{ "lang": "rust", "repo": "Ryan-Git/learn-rust", "path": "/src/ch7_modules.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod a { pub mod series { pub mod of { pub fn nested_modules() {} } } }<|fim_prefix|>// repo: Ryan-Git/learn-rust path: /src/ch7_modules.rs //see project communicator //Rules of Module Filesystems // //Let’s summarize the rules of modules with regard to files: // /...
code_fim
hard
{ "lang": "rust", "repo": "Ryan-Git/learn-rust", "path": "/src/ch7_modules.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ryan-Git/learn-rust path: /src/ch15_smart_pointers/ch15_1_box.rs #[test] fn test_box() { //Boxes allow you to put a single value on the heap let b = Box::new(5); println!("b = {}", b); } enum List<T> { Cons(T, Box<List<T>>), Nil } //This is the main area where boxes are use...
code_fim
hard
{ "lang": "rust", "repo": "Ryan-Git/learn-rust", "path": "/src/ch15_smart_pointers/ch15_1_box.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(6, x); let my_fav_song = Mp3 { audio: vec![1, 2, 3], artist: Some(String::from("Nirvana")), title: Some(String::from("Smells Like Teen Spirit")), }; assert_eq!(vec![1, 2, 3], *my_fav_song); //deref coercion //A deref coercion will automatically...
code_fim
hard
{ "lang": "rust", "repo": "Ryan-Git/learn-rust", "path": "/src/ch15_smart_pointers/ch15_1_box.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *y += 1 } assert_eq!(6, x); let my_fav_song = Mp3 { audio: vec![1, 2, 3], artist: Some(String::from("Nirvana")), title: Some(String::from("Smells Like Teen Spirit")), }; assert_eq!(vec![1, 2, 3], *my_fav_song); //deref coercion //A deref coer...
code_fim
hard
{ "lang": "rust", "repo": "Ryan-Git/learn-rust", "path": "/src/ch15_smart_pointers/ch15_1_box.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davefol/rust-genomics path: /src/index_of_association.rs use crate::prelude::*; use ndarray; use std::collections::HashMap; use std::error::Error; pub struct IndexOfAssociationSummary { index_of_association: f32, } pub trait IndexOfAssociation { fn index_of_association(&mut self) -> Re...
code_fim
hard
{ "lang": "rust", "repo": "davefol/rust-genomics", "path": "/src/index_of_association.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (0..n_freqs - 1).for_each(|i| { ((i + 1)..n_freqs).for_each(|j| { self.matrix .loci .iter() .enumerate() .for_each(|(idx, (start, end))| { distances[[indices[&(i, j)]...
code_fim
hard
{ "lang": "rust", "repo": "davefol/rust-genomics", "path": "/src/index_of_association.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }