text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: prisma/prisma-engines path: /query-engine/core/src/query_graph_builder/extractors/mod.rs mod filters; mod query_arguments; mod rel_aggregations; mod utils; <|fim_suffix|>use crate::query_document::*;<|fim_middle|>pub(crate) use filters::*; pub(crate) use query_arguments::*; pub(crate) use rel_a...
code_fim
medium
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/core/src/query_graph_builder/extractors/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let constraints_from_leaf = cs.num_constraints() - constraints_from_parameters - constraints_from_digest; println!("constraints from leaf: {}", constraints_from_leaf); // Allocate Merkle Tree Path let cw = MerkleSparseTreePathVar::<_, HG, _>...
code_fim
hard
{ "lang": "rust", "repo": "3for/ivls", "path": "/src/building_blocks/mt/merkle_sparse_tree/constraints.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 3for/ivls path: /src/building_blocks/mt/merkle_sparse_tree/constraints.rs RHVar::hash_bytes(parameters, &leaf_bits)?; // Check levels between leaf level and root. let mut previous_hash = leaf_hash; let index_bits = index.to_bits_le(); for (i, &(ref left_hash, ref...
code_fim
hard
{ "lang": "rust", "repo": "3for/ivls", "path": "/src/building_blocks/mt/merkle_sparse_tree/constraints.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 3for/ivls path: /src/building_blocks/mt/merkle_sparse_tree/constraints.rs eft_hash, ref right_hash)) in self.path.iter().enumerate() { // Check if the previous_hash matches the correct current hash. let previous_is_left = index_bits[i].not(); previous_hash.co...
code_fim
hard
{ "lang": "rust", "repo": "3for/ivls", "path": "/src/building_blocks/mt/merkle_sparse_tree/constraints.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mathw/adventofcode path: /aoc2022/src/day.rs use std::error::Error; use std::fmt::Display; pub trait Day { fn run(&mut self) -> Result; } pub type Result = std::result::Result<DayResult, Box<dyn Error>>; pub enum PartResult { Success(String), NotImplemented, } pub struct DayResul...
code_fim
medium
{ "lang": "rust", "repo": "mathw/adventofcode", "path": "/aoc2022/src/day.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for DayResult { fn default() -> Self { DayResult { part1: PartResult::NotImplemented, part2: PartResult::NotImplemented, } } } impl Display for PartResult { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt:...
code_fim
hard
{ "lang": "rust", "repo": "mathw/adventofcode", "path": "/aoc2022/src/day.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for DayResult { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { write!(f, "PART ONE: {}\n", self.part1)?; write!(f, "PART TWO: {}\n", self.part2) } }<|fim_prefix|>// repo: mathw/adventofcode path: /aoc2022/src/day.rs use st...
code_fim
hard
{ "lang": "rust", "repo": "mathw/adventofcode", "path": "/aoc2022/src/day.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for line in s.lines() { let points = line.split(" -> ").collect::<Vec<&str>>(); let mut prev = Point::new(points[0]); g.grid.insert(prev.clone(), '#'); for i in 1..points.len() { let cur = Point::new(points[i]); let d...
code_fim
hard
{ "lang": "rust", "repo": "icub3d/puzzles", "path": "/advent-of-code/2022/day14/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: icub3d/puzzles path: /advent-of-code/2022/day14/src/main.rs use std::{ collections::HashMap, fmt, fs, ops::{Add, AddAssign}, }; #[derive(PartialEq, Eq, Hash, Clone, Debug)] struct Point { x: isize, y: isize, } impl Point { fn new(s: &str) -> Point { let p = s ...
code_fim
hard
{ "lang": "rust", "repo": "icub3d/puzzles", "path": "/advent-of-code/2022/day14/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if p.x < self.min.x { self.min.x = p.x; } if p.x > self.max.x { self.max.x = p.x; } if p.y > self.max.y { self.max.y = p.y; } } fn get(&self, p: &Point, floor: bool) -> Option<&char> { if floor && p.y == s...
code_fim
hard
{ "lang": "rust", "repo": "icub3d/puzzles", "path": "/advent-of-code/2022/day14/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut frame = sciter::Window::new(); let html_file_path = PathBuf::from("./app.html"); let html_file = fs::canonicalize(&html_file_path).unwrap(); frame.load_file(html_file.to_str().unwrap()); frame.run_app(); }<|fim_prefix|>// repo: davidedelpapa/rust-ui-sciter path: /...
code_fim
easy
{ "lang": "rust", "repo": "davidedelpapa/rust-ui-sciter", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut frame = sciter::Window::new(); let html_file_path = PathBuf::from("./app.html"); let html_file = fs::canonicalize(&html_file_path).unwrap(); frame.load_file(html_file.to_str().unwrap()); frame.run_app(); }<|fim_prefix|>// repo: davidedelpapa/rust-ui-sciter path: /src/main.rs ...
code_fim
easy
{ "lang": "rust", "repo": "davidedelpapa/rust-ui-sciter", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davidedelpapa/rust-ui-sciter path: /src/main.rs use std::fs; use std::path::PathBuf; <|fim_suffix|> let mut frame = sciter::Window::new(); let html_file_path = PathBuf::from("./app.html"); let html_file = fs::canonicalize(&html_file_path).unwrap(); frame.load_file(html_file.to_s...
code_fim
easy
{ "lang": "rust", "repo": "davidedelpapa/rust-ui-sciter", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nitrokey/nitrokey-3-firmware path: /runners/embedded/src/soc_lpc55/monotonic.rs use embedded_time::duration::units::Milliseconds; use systick_monotonic::{ fugit::{MillisDurationU64, TimerDurationU64, TimerInstantU64}, Systick, }; pub type SystickMonotonic = MonotonicWrapper<Systick<100>...
code_fim
hard
{ "lang": "rust", "repo": "Nitrokey/nitrokey-3-firmware", "path": "/runners/embedded/src/soc_lpc55/monotonic.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.0.on_interrupt(); } fn enable_timer(&mut self) { self.0.enable_timer(); } fn disable_timer(&mut self) { self.0.disable_timer(); } } impl<M: rtic::Monotonic> From<M> for MonotonicWrapper<M> { fn from(monotonic: M) -> Self { Self(monotonic) ...
code_fim
hard
{ "lang": "rust", "repo": "Nitrokey/nitrokey-3-firmware", "path": "/runners/embedded/src/soc_lpc55/monotonic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jorian/iln_snapshot path: /src/main.rs extern crate komodo_airdrop; extern crate komodo_rpc_client; extern crate csv; extern crate serde; extern crate chrono; use komodo_airdrop::Snapshot; use komodo_rpc_client::Chain; use std::collections::HashMap; use csv::Error; fn main() { <|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "jorian/iln_snapshot", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut writer = csv::Writer::from_path(format!("./snapshot_{}.csv", date)).expect("Problem while creating snapshot file"); map.iter().for_each(|(key, value)| { writer.serialize((key, value)).expect("Problem during serialization"); }); Ok(()) }<|fim_prefix|>// repo: jorian/iln_sn...
code_fim
hard
{ "lang": "rust", "repo": "jorian/iln_snapshot", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: feather-rs/feather path: /feather/blocks/src/directions.rs use crate::{AxisXyz, FacingCardinal, FacingCardinalAndDown, FacingCubic}; use vek::Vec3; impl FacingCardinal { pub fn opposite(self) -> FacingCardinal { match self { FacingCardinal::North => FacingCardinal::South...
code_fim
hard
{ "lang": "rust", "repo": "feather-rs/feather", "path": "/feather/blocks/src/directions.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn offset(self) -> Vec3<i32> { self.to_facing_cubic().offset() } } impl FacingCardinalAndDown { pub fn opposite(self) -> Option<FacingCardinalAndDown> { match self { FacingCardinalAndDown::North => Some(FacingCardinalAndDown::South), FacingCardinalA...
code_fim
hard
{ "lang": "rust", "repo": "feather-rs/feather", "path": "/feather/blocks/src/directions.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf-pacs path: /pacs/nrf52805-pac/src/clock/lfclkstat.rs #[doc = "Register `LFCLKSTAT` reader"] pub struct R(crate::R<LFCLKSTAT_SPEC>); impl core::ops::Deref for R { type Target = crate::R<LFCLKSTAT_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 ...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf-pacs", "path": "/pacs/nrf52805-pac/src/clock/lfclkstat.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: petrosagg/pubnub-rust path: /pubnub-core/src/data/mod.rs //! Data structs and enums. pub mod channel; pub mod history; pub mod message; pub mod object; pub mod pam; pub <|fim_suffix|>esponse; pub mod target; pub mod timetoken; pub mod uuid;<|fim_middle|>mod presence; pub mod pubsub; pub mod req...
code_fim
easy
{ "lang": "rust", "repo": "petrosagg/pubnub-rust", "path": "/pubnub-core/src/data/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod presence; pub mod pubsub; pub mod request; pub mod response; pub mod target; pub mod timetoken; pub mod uuid;<|fim_prefix|>// repo: petrosagg/pubnub-rust path: /pubnub-core/src/data/mod.rs //! Data structs and enums. pub mod channel; pub mod hi<|fim_middle|>story; pub mod message; pub mod object; pu...
code_fim
easy
{ "lang": "rust", "repo": "petrosagg/pubnub-rust", "path": "/pubnub-core/src/data/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: delbato/wrap-archive path: /src/write/writer.rs use std::io::{ Seek, SeekFrom, Write, }; use bincode::serialize_into as bincode_write; use crate::shared::archive_header::ArchiveHeader; use crate::shared::compression::Compression; use crate::shared::directory::Directory; use crate::...
code_fim
medium
{ "lang": "rust", "repo": "delbato/wrap-archive", "path": "/src/write/writer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let directory_begin = self.sink.seek(SeekFrom::End(0)).unwrap(); bincode_write(&mut self.sink, &self.directory).unwrap(); let directory_end = self.sink.seek(SeekFrom::Current(0)).unwrap(); self.sink.seek(SeekFrom::Start(4)).unwrap(); let mut archive_header = Archive...
code_fim
medium
{ "lang": "rust", "repo": "delbato/wrap-archive", "path": "/src/write/writer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_hash() { let mut data = [0u8; 256]; for i in 0..256 { data[i as usize] = i as u8; } assert_eq!(hash(&data[..253][..]), 4252827879u32); assert_eq!(hash(&data[..254][..]), 1201313498u32); assert_eq!(hash(&data[..255][..]), 4...
code_fim
hard
{ "lang": "rust", "repo": "scturtle/turtledb", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scturtle/turtledb path: /src/utils.rs use integer_encoding::FixedInt; use std::borrow::Borrow; pub fn hash<T: Borrow<[u8]>>(data: T) -> u32 { let data = data.borrow(); const SEED: u32 = 0xbc9f1d34; const M: u32 = 0xc6a4a793; const R: u32 = 24; let n = data.len(); let mut...
code_fim
hard
{ "lang": "rust", "repo": "scturtle/turtledb", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn set_connectors(&self, connectors: &[connector::Handle]) -> Result<(), Self::Error> { if connectors.is_empty() { return Err(Error::SurfaceWithoutConnectors(self.crtc)); } if !self.dev.active.load(Ordering::SeqCst) { return Err(Error::DeviceInactive); ...
code_fim
hard
{ "lang": "rust", "repo": "tristan-zander/smithay", "path": "/src/backend/drm/legacy/surface.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tristan-zander/smithay path: /src/backend/drm/legacy/surface.rs t_cursor_position(&self, x: u32, y: u32) -> Result<(), Error> { if !self.dev.active.load(Ordering::SeqCst) { return Err(Error::DeviceInactive); } trace!(self.logger, "Move the cursor to {},{}", x...
code_fim
hard
{ "lang": "rust", "repo": "tristan-zander/smithay", "path": "/src/backend/drm/legacy/surface.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut pending = self.pending.write().unwrap(); // check the connectors to see if this mode is supported for connector in &pending.connectors { if !self .get_connector(*connector) .compat() .map_err(|source| Error::Acces...
code_fim
hard
{ "lang": "rust", "repo": "tristan-zander/smithay", "path": "/src/backend/drm/legacy/surface.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Yasushi/nlp100-rs path: /src/bin/nlp18.rs use std::env; use std::fs::File; use std::io::{BufRead, BufReader, Write}; use std::str::FromStr; fn key(line: &String) -> f32 { <|fim_suffix|>/// 18. 各行を3コラム目の数値の降順にソート /// 各行を3コラム目の数値の逆順で整列せよ(注意: 各行の内容は変更せず /// に並び替えよ).確認にはsortコマンドを用いよ(この問題はコマンドで /// ...
code_fim
hard
{ "lang": "rust", "repo": "Yasushi/nlp100-rs", "path": "/src/bin/nlp18.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let x = (key(x) * 10.0) as i32; let y = (key(y) * 10.0) as i32; y.cmp(&x) } /// 18. 各行を3コラム目の数値の降順にソート /// 各行を3コラム目の数値の逆順で整列せよ(注意: 各行の内容は変更せず /// に並び替えよ).確認にはsortコマンドを用いよ(この問題はコマンドで /// 実行した時の結果と合わなくてもよい). pub fn main() { let filename = env::args().skip(1).next().unwrap(); let f = Fil...
code_fim
medium
{ "lang": "rust", "repo": "Yasushi/nlp100-rs", "path": "/src/bin/nlp18.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for l in lines { std::io::stdout().write_fmt(format_args!("{}\n", l)).unwrap(); } }<|fim_prefix|>// repo: Yasushi/nlp100-rs path: /src/bin/nlp18.rs use std::env; use std::fs::File; use std::io::{BufRead, BufReader, Write}; use std::str::FromStr; fn key(line: &String) -> f32 { <|fim_midd...
code_fim
hard
{ "lang": "rust", "repo": "Yasushi/nlp100-rs", "path": "/src/bin/nlp18.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/futures-rs path: /futures/tests/future_shared.rs use futures::channel::oneshot; use futures::executor::{block_on, LocalPool}; use futures::future::{self, FutureExt, LocalFutureObj, TryFutureExt}; use futures::task::LocalSpawn; use std::cell::{Cell, RefCell}; use std::panic::AssertUnwin...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/futures-rs", "path": "/futures/tests/future_shared.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Now that `shared2` has completed, `ptr_eq` should return false. assert!(shared2.is_terminated()); assert!(!shared.ptr_eq(&shared2)); // `ptr_eq` should continue to work for the other `Shared`. let shared3 = shared.clone(); let mut hasher3 = DefaultHasher::new(); assert!(sha...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/futures-rs", "path": "/futures/tests/future_shared.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ccp-project/portus path: /tests/volatile.rs use portus::lang::Scope; use portus::{DatapathTrait, Report}; use std::collections::HashMap; use tracing::info; mod libccp_integration; use crate::libccp_integration::IntegrationTest; pub struct TestVolatileVars; impl IntegrationTest for TestVolatil...
code_fim
hard
{ "lang": "rust", "repo": "ccp-project/portus", "path": "/tests/volatile.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> dp.set_program("TestVolatileVars", None).ok() } fn check_test( &mut self, sc: &Scope, _t: std::time::Instant, _sock_id: u32, m: &Report, ) -> bool { let foo = m.get_field("Report.foo", sc).expect("get Report.foo"); let bar = m.ge...
code_fim
hard
{ "lang": "rust", "repo": "ccp-project/portus", "path": "/tests/volatile.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>AggregationGroup = *mut ::core::ffi::c_void; pub type IContactAggregationGroupCollection = *mut ::core::ffi::c_void; pub type IContactAggregationLink = *mut ::core::ffi::c_void; pub type IContactAggregationLinkCollection = *mut ::core::ffi::c_void; pub type IContactAggregationManager = *mut ::core::ffi::c...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/crates/deps/sys/src/Windows/Win32/System/Contacts/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/deps/sys/src/Windows/Win32/System/Contacts/mod.rs #![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" {} pub const CGD_ARRAY_NODE: u32 = 8u32; pub co...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/crates/deps/sys/src/Windows/Win32/System/Contacts/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/shared-arena path: /src/arena.rs caller responsability to initialize properly the value. /// When all [`ArenaArc`] pointing that value are dropped, the value /// is also dropped. If the value is not initialized correctly, it will /// drop an unitialized value, which is undef...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/shared-arena", "path": "/src/arena.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (used, free) } #[cfg(target_pointer_width = "64") ] #[cfg(test)] pub(crate) fn size_lists(&self) -> (usize, usize, usize) { let mut next = self.full_list.load(Relaxed); let mut size = 0; while let Some(next_ref) = unsafe { next.as_mut() } { next...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/shared-arena", "path": "/src/arena.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/shared-arena path: /src/arena.rs rust-lang.org/std/mem/union.MaybeUninit.html pub fn alloc_with<F>(&self, initializer: F) -> ArenaBox<T> where F: Fn(&mut MaybeUninit<T>) { let block = self.find_place(); unsafe { let ptr = block.as_ref().va...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/shared-arena", "path": "/src/arena.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Draphar/redditrip path: /src/sites/reddit.rs /* * Copyright 2020 Draphar * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICE...
code_fim
hard
{ "lang": "rust", "repo": "Draphar/redditrip", "path": "/src/sites/reddit.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let video_url = format!("https://v.redd.it/{}/DASH_{}", id, resolution).parse()?; let video_path = temp_dir.with_file_name(format!("v_redd_it_{}_video", id)); let audio_url = format!("https://v.redd.it/{}/audio", id).parse()?; let audio_path = temp_dir.with_file_name(format!("v_redd_it_{}_...
code_fim
hard
{ "lang": "rust", "repo": "Draphar/redditrip", "path": "/src/sites/reddit.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if video.is_err() && audio.is_err() { clear(&video_path, &audio_path).await; if let Err(e) = video { return Err(Error::new(format!( "Failed to combine audio and video: {}", e ))); }; if let Err(e) = audio { ...
code_fim
hard
{ "lang": "rust", "repo": "Draphar/redditrip", "path": "/src/sites/reddit.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eeeeeta/matrix-extractor-hacky path: /src/main.rs extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate csv; extern crate failure; extern crate gm_types; extern crate chrono; use std::io; use gm_types::events::Event; use gm_types::content::Content; us...
code_fim
hard
{ "lang": "rust", "repo": "eeeeeta/matrix-extractor-hacky", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rdr = csv::ReaderBuilder::new() .delimiter(b'\t') .has_headers(false) .from_reader(io::stdin()); let mut bmap = BTreeMap::new(); for rec in rdr.deserialize() { let rec: EventJsonLine = rec?; let meta: Metadata = match ::serde_json::from_str(&rec....
code_fim
hard
{ "lang": "rust", "repo": "eeeeeta/matrix-extractor-hacky", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(feature = "serde")] pub(crate) use serde::{Deserialize, Serialize}; pub(crate) use std::{ boxed::Box, clone::Clone, cmp::Ord, convert::{From, Into}, default::Default, error::Error, fmt::{Debug, Display, Formatter, Result as FmtResu...
code_fim
hard
{ "lang": "rust", "repo": "co42/bevy_tilemap", "path": "/library/types/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// A custom prelude around all the types we need from `std`, `bevy`, and `serde`. #[no_implicit_prelude] mod lib { extern crate bevy_math; extern crate bevy_render; #[cfg(feature = "serde")] extern crate serde; extern crate std; pub(crate) use self::{ bevy_math::{Vec2, Ve...
code_fim
medium
{ "lang": "rust", "repo": "co42/bevy_tilemap", "path": "/library/types/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: co42/bevy_tilemap path: /library/types/src/lib.rs //! # Bevy Tilemap Types //! //! All the extra or helpful types that are not supported by Bevy or Glam are //! all contained here. #![doc(html_root_url = "https://docs.rs/bevy_tilemap_types/0.4.0")] // This was broken even further and no longer ...
code_fim
hard
{ "lang": "rust", "repo": "co42/bevy_tilemap", "path": "/library/types/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `RWKUP` reader - Remote wakeup"] pub type RWKUP_R = crate::BitReader<bool>; #[doc = "Field `RWKUP` writer - Remote wakeup"] pub type RWKUP_W<'a, const O: u8> = crate::BitWriter<'a, u32, DCTL_SPEC, bool, O>; #[doc = "Field `SD` reader - Soft disconnect"] pub type SD...
code_fim
hard
{ "lang": "rust", "repo": "riscv-rust/gd32vf103-pac", "path": "/src/usbfs_device/dctl.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: riscv-rust/gd32vf103-pac path: /src/usbfs_device/dctl.rs #[doc = "Register `DCTL` reader"] pub struct R(crate::R<DCTL_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DCTL_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate:...
code_fim
hard
{ "lang": "rust", "repo": "riscv-rust/gd32vf103-pac", "path": "/src/usbfs_device/dctl.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ves-lang/ves path: /ves-parser/examples/usage.rs fn main() { use ves_error::VesFileDatabase; use ves_parser::{Lexer, Parser}; <|fim_suffix|> // Add the file to the database and get its ID let mut db = VesFileDatabase::default(); let id = db.add_snippet(source); // Create...
code_fim
medium
{ "lang": "rust", "repo": "ves-lang/ves", "path": "/ves-parser/examples/usage.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Create a parser for the given file ID, and run it let ast = match Parser::new(Lexer::new(&source), id, &db).parse() { Ok(ast) => ast, Err(ex) => return db.report(&ex).unwrap(), }; // The AST contains the imports, exports, globals, and every statement in the body. pr...
code_fim
medium
{ "lang": "rust", "repo": "ves-lang/ves", "path": "/ves-parser/examples/usage.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SwapnilGaikwad/lsp-asm path: /crates/base/src/lib.rs #[macro_use] extern crate log; #[macro_use] extern crate lazy_static; mod architecture; pub use architecture::*; <|fim_suffix|>pub mod register;<|fim_middle|>mod filetype; pub use filetype::*;
code_fim
easy
{ "lang": "rust", "repo": "SwapnilGaikwad/lsp-asm", "path": "/crates/base/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub mod register;<|fim_prefix|>// repo: SwapnilGaikwad/lsp-asm path: /crates/base/src/lib.rs #[macro_use] extern crate log; #[macro_use] extern crate lazy_static; <|fim_middle|>mod architecture; pub use architecture::*; mod filetype; pub use filetype::*;
code_fim
medium
{ "lang": "rust", "repo": "SwapnilGaikwad/lsp-asm", "path": "/crates/base/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: venturecommunism/react-app path: /apps/exmacaroons/native/rustmacaroons/src/lib.rs #[macro_use] extern crate rustler; #[macro_use] extern crate lazy_static; extern crate macaroons; use rustler::{NifEnv, NifTerm, NifResult, NifEncoder}; mod atoms { rustler_atoms! { atom ok; } } ...
code_fim
hard
{ "lang": "rust", "repo": "venturecommunism/react-app", "path": "/apps/exmacaroons/native/rustmacaroons/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn example_third_party_caveat() -> Caveat { Caveat::third_party(example_caveat_key(), example_third_party_caveat_id(), example_third_party_caveat_location()) } fn example_token() -> V1Token { V1Token::new(&example_key(), example_id(), Some(example_u...
code_fim
hard
{ "lang": "rust", "repo": "venturecommunism/react-app", "path": "/apps/exmacaroons/native/rustmacaroons/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Vec::from("4; guaranteed random by a fair toss of the dice") } fn example_third_party_caveat_id() -> Vec<u8> { Vec::from("this was how we remind auth of key/pred") } fn example_third_party_caveat_location() -> Vec<u8> { Vec::from("http://auth.mybank/") } fn example_third_party_caveat() -> C...
code_fim
hard
{ "lang": "rust", "repo": "venturecommunism/react-app", "path": "/apps/exmacaroons/native/rustmacaroons/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCrawl/myrias path: /src/router.rs pub mod cleanup; pub mod containers; pub m<|fim_suffix|>gateway_timeout; pub mod internal_server_error; pub mod languages; pub mod not_found;<|fim_middle|>od create_container; pub mod eval; pub mod
code_fim
easy
{ "lang": "rust", "repo": "iCrawl/myrias", "path": "/src/router.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>rror; pub mod languages; pub mod not_found;<|fim_prefix|>// repo: iCrawl/myrias path: /src/router.rs pub mod cleanup; pub mod containers; pub mod create_container; pub mod eval; pub mod <|fim_middle|>gateway_timeout; pub mod internal_server_e
code_fim
easy
{ "lang": "rust", "repo": "iCrawl/myrias", "path": "/src/router.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>gateway_timeout; pub mod internal_server_error; pub mod languages; pub mod not_found;<|fim_prefix|>// repo: iCrawl/myrias path: /src/router.rs pub mod cleanup; pub mod containers; pub m<|fim_middle|>od create_container; pub mod eval; pub mod
code_fim
easy
{ "lang": "rust", "repo": "iCrawl/myrias", "path": "/src/router.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn main() { let args: Vec<String> = env::args().collect(); if args.len() < 2 { println!("usage: pokemon input.txt [--parallel]"); return } let mut filename: Option<String> = None; let mut parallel = false; for arg in args { if arg == "--parallel" { ...
code_fim
hard
{ "lang": "rust", "repo": "resonancellc/pokemon", "path": "/pokemon.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: resonancellc/pokemon path: /pokemon.rs extern crate rayon; use rayon::prelude::*; use rayon::iter::{IntoParallelIterator, ParallelIterator}; use std::env; use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::time::Duration; use std::time::SystemTime; const M: usize = 150;...
code_fim
hard
{ "lang": "rust", "repo": "resonancellc/pokemon", "path": "/pokemon.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let _up:GoUp = argh::from_env(); }<|fim_prefix|>// repo: dougtq/rust-lang path: /playground/argh-fun/src/main.rs extern crate argh; use argh::FromArgs; #[derive(FromArgs)] /// Reach new heights. struct GoUp { /// whether or not to jump #[argh(switch, short = 'j')] jump: bool...
code_fim
medium
{ "lang": "rust", "repo": "dougtq/rust-lang", "path": "/playground/argh-fun/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dougtq/rust-lang path: /playground/argh-fun/src/main.rs extern crate argh; use argh::FromArgs; #[derive(FromArgs)] /// Reach new heights. struct GoUp { /// whether or not to jump #[argh(switch, short = 'j')] jump: bool, <|fim_suffix|> /// an optional nickname for the pilot ...
code_fim
medium
{ "lang": "rust", "repo": "dougtq/rust-lang", "path": "/playground/argh-fun/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let maybe_caps = re.captures(&line); match maybe_caps { None => { // do nothing }, Some(captures) => *last_date = Some((&captures[1]).to_owned()), } } fn update_entry_with_date(last_date : &Option<String>, line : &str, re: &Regex){ match *last_date { ...
code_fim
medium
{ "lang": "rust", "repo": "StyMaar/rte-clean", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match *last_date { Some(ref date) => { if re.is_match(line) { println!("{} {}",date, line); } } None => panic!() } }<|fim_prefix|>// repo: StyMaar/rte-clean path: /src/main.rs use std::io::BufReader; use std::io::BufRead; use std::fs...
code_fim
hard
{ "lang": "rust", "repo": "StyMaar/rte-clean", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StyMaar/rte-clean path: /src/main.rs use std::io::BufReader; use std::io::BufRead; use std::fs::File; extern crate regex; use regex::Regex; fn main() { let re_date = Regex::new(r"^Données de réalisation du (\d{2}/\d{2}/\d{4})$").unwrap(); let re_entry = Regex::new(r"^\d").unwrap(); ...
code_fim
medium
{ "lang": "rust", "repo": "StyMaar/rte-clean", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the intermediate state of the accumulator. /// /// Intermediate state is used for "multi-phase" grouping in /// DataFusion, where an aggregate is computed in parallel with /// multiple `Accumulator` instances, as illustrated below: /// /// # MultiPhase Grouping ...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/expr/src/accumulator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the final aggregate value. /// /// For example, the `SUM` accumulator maintains a running sum, /// and `evaluate` will produce that running sum as its output. fn evaluate(&self) -> Result<ScalarValue>; /// Returns the allocated size required for this accumulator, in ...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/expr/src/accumulator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/expr/src/accumulator.rs // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF l...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/expr/src/accumulator.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dureuill/itrs path: /src/wrap.rs //! Define `ItrsWrap`, that wraps an iterable python object as a rust Iterator use pyo3::prelude::*; #[pyclass] pub struct ItrsWrap { iter: PyObject, } impl ItrsWrap { pub fn with_wrap(iter: PyObject, py: Python<'_>) -> PyResult<Self> { let ite...
code_fim
hard
{ "lang": "rust", "repo": "dureuill/itrs", "path": "/src/wrap.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<PyResult<PyObject>> { let gil = Python::acquire_gil(); let py = gil.python(); match self.iter.call_method0(py, "__next__") { Ok(result) => Some(Ok(result)), Err(err) => { if err.is_instance::<pyo3::exceptions:...
code_fim
medium
{ "lang": "rust", "repo": "dureuill/itrs", "path": "/src/wrap.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if len != 16 { ptr = ptr.add(16); let read_ptr = end_ptr.sub(16); let backs = 32 - len; let mut mask = maskgen(_mm_loadu_si128(read_ptr as *const __m128i)) >> backs; while mask != 0 { let trailing_zeros = mask.trailing_zeros() as usize; ...
code_fim
hard
{ "lang": "rust", "repo": "untoreh/sailfish", "path": "/sailfish/src/runtime/escape/avx2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: untoreh/sailfish path: /sailfish/src/runtime/escape/avx2.rs #![allow(clippy::cast_ptr_alignment)] #[cfg(target_arch = "x86")] use std::arch::x86::*; #[cfg(target_arch = "x86_64")] use std::arch::x86_64::*; use std::slice; use super::super::Buffer; use super::naive::push_escaped_str; use super:...
code_fim
hard
{ "lang": "rust", "repo": "untoreh/sailfish", "path": "/sailfish/src/runtime/escape/avx2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match event.chain_err(|| Error::from("error while parsing person event"))? { ParseEvent::Ignore => { reader.next(); } ParseEvent::StartName => { person.name = Some(string::consume(reader)?); } ParseEvent:...
code_fim
hard
{ "lang": "rust", "repo": "zudov/rust-gpx", "path": "/src/parser/person.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zudov/rust-gpx path: /src/parser/person.rs //! person handles parsing of GPX-spec persons. use errors::*; use std::iter::Peekable; use std::io::Read; use xml::reader::Events; use xml::reader::XmlEvent; use parser::email; use parser::link; use parser::string; use Person; enum ParseEvent { ...
code_fim
hard
{ "lang": "rust", "repo": "zudov/rust-gpx", "path": "/src/parser/person.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Veykril/pixelsort path: /src/sorting.rs use image::Pixel; #[inline] pub fn lightness<P>(pixel: &P) -> u32 where P: Pixel<Subpixel = u8>, { pixel.to_luma()[0] as u32 } #[inline] pub fn intensity<P>(pixel: &P) -> u32 where P: Pixel<Subpixel = u8>, { pixel.channels().iter().map(|c...
code_fim
medium
{ "lang": "rust", "repo": "Veykril/pixelsort", "path": "/src/sorting.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[inline] pub fn chan_max<P>(pixel: &P) -> u32 where P: Pixel<Subpixel = u8>, { pixel.channels().iter().copied().max().unwrap_or(255) as u32 }<|fim_prefix|>// repo: Veykril/pixelsort path: /src/sorting.rs use image::Pixel; #[inline] pub fn lightness<P>(pixel: &P) -> u32 where P: Pixel<Subpix...
code_fim
medium
{ "lang": "rust", "repo": "Veykril/pixelsort", "path": "/src/sorting.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aylei/leetcode-rust path: /src/solution/s0061_rotate_list.rs /** * [61] Rotate List * * Given a linked list, rotate the list to the right by k places, where k is non-negative. * * Example 1: * * * Input: 1->2->3->4->5->NULL, k = 2 * Output: 4->5->1->2->3->NULL * Explanation: * rotate ...
code_fim
medium
{ "lang": "rust", "repo": "aylei/leetcode-rust", "path": "/src/solution/s0061_rotate_list.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// submission codes start here impl Solution { pub fn rotate_right(head: Option<Box<ListNode>>, k: i32) -> Option<Box<ListNode>> { None } } // submission codes end #[cfg(test)] mod tests { use super::*; #[test] fn test_61() {} }<|fim_prefix|>// repo: aylei/leetcode-rust pa...
code_fim
medium
{ "lang": "rust", "repo": "aylei/leetcode-rust", "path": "/src/solution/s0061_rotate_list.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: second-state/wasm-learning path: /cli/wasi/src/main.rs use rand::prelude::*; use std::fs; use std::fs::File; use std::io::{Write, Read}; use std::env; fn main() { println!("Random number: {}", get_random_i32()); println!("Random bytes: {:?}", get_random_bytes()); println!("{}", echo("This...
code_fim
hard
{ "lang": "rust", "repo": "second-state/wasm-learning", "path": "/cli/wasi/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn create_file(path: &str, content: &str) { let mut output = File::create(path).unwrap(); output.write_all(content.as_bytes()).unwrap(); } pub fn read_file(path: &str) -> String { let mut f = File::open(path).unwrap(); let mut s = String::new(); match f.read_to_string(&mut s) { Ok(_) =>...
code_fim
hard
{ "lang": "rust", "repo": "second-state/wasm-learning", "path": "/cli/wasi/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn read_file(path: &str) -> String { let mut f = File::open(path).unwrap(); let mut s = String::new(); match f.read_to_string(&mut s) { Ok(_) => s, Err(e) => e.to_string(), } } pub fn del_file(path: &str) { fs::remove_file(path).expect("Unable to delete"); }<|fim_prefix|>// repo: se...
code_fim
hard
{ "lang": "rust", "repo": "second-state/wasm-learning", "path": "/cli/wasi/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/src/ts/declarations/interface_declaration.rs use crate::prelude::*; use rome_formatter::{format_args, write}; use rome_js_syntax::{TsInterfaceDeclaration, TsInterfaceDeclarationFields}; #[derive(Debug, Clone, Default)] pub struct FormatTsInterfaceDecl...
code_fim
hard
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/ts/declarations/interface_declaration.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if members.is_empty() { write!( f, [format_dangling_comments(node.syntax()).with_block_indent()] )?; } else { write!(f, [block_indent(&members.format())])?; } write!(f, ...
code_fim
hard
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/ts/declarations/interface_declaration.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RicoGit/rust-alg path: /src/leetcode/longest_string_chain.rs //! 1048. Longest String Chain use std::cmp::Reverse; impl Solution { pub fn longest_str_chain(mut words: Vec<String>) -> i32 { words.sort_by_key(|w| Reverse(w.len())); let mut cache = vec![1; words.len()]; ...
code_fim
hard
{ "lang": "rust", "repo": "RicoGit/rust-alg", "path": "/src/leetcode/longest_string_chain.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while idx1 < w1.len() || idx2 < w1.len() { if w1[idx1] == w2[idx2] { idx1 += 1; idx2 += 1; } else { if not_eq { return false; } not_eq = true; idx2 += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "RicoGit/rust-alg", "path": "/src/leetcode/longest_string_chain.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if is_predecessor(words[next_idx].as_bytes(), words[idx].as_bytes()) { cache[idx] = cache[idx].max(Self::chain_length(words, cache, next_idx) + 1); } } cache[idx] } } fn is_predecessor(w1: &[u8], w2: &[u8]) -> bool { if w1.len() == w2.len()...
code_fim
hard
{ "lang": "rust", "repo": "RicoGit/rust-alg", "path": "/src/leetcode/longest_string_chain.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> trace!("logging initialised"); let try_parsed_args = FormOpts::from_args().context("could not parse the command line arguments")?; // if None, we've already printed a help text and have nothing more to do if let Some(opts) = try_parsed_args { create_directory_structure(opts...
code_fim
hard
{ "lang": "rust", "repo": "dbrgn/form", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dbrgn/form path: /src/main.rs #![recursion_limit = "1024"] extern crate getopts; extern crate quote; extern crate syn; #[macro_use] extern crate log; extern crate env_logger; extern crate failure; use log::LevelFilter; mod opts; use crate::opts::FormOpts; use failure::*; mod util; use crate::...
code_fim
medium
{ "lang": "rust", "repo": "dbrgn/form", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn estimate_price(mileage: f32, theta0: f32, theta1: f32) -> f32 { (theta0 + (theta1 * mileage)) }<|fim_prefix|>// repo: Kerollmops/linear-regression path: /src/bin/common/mod.rs pub static TMP_FILE_THETAS: &'static str = ".thetas_values.csv"; pub static TMP_FILE_MIN_MAX: &'static str = ".min_max...
code_fim
medium
{ "lang": "rust", "repo": "Kerollmops/linear-regression", "path": "/src/bin/common/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kerollmops/linear-regression path: /src/bin/common/mod.rs pub static TMP_FILE_THETAS: &'static str = ".thetas_values.csv"; pub static TMP_FILE_MIN_MAX: &'static str = ".min_max_values.csv"; <|fim_suffix|>pub fn estimate_price(mileage: f32, theta0: f32, theta1: f32) -> f32 { (theta0 + (theta...
code_fim
medium
{ "lang": "rust", "repo": "Kerollmops/linear-regression", "path": "/src/bin/common/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhang-zw123/vchain-demo path: /vchain-exonum/src/schema.rs use crate::transactions::RawObject; use anyhow::{Context, Error, Result}; use exonum::crypto::Hash; use exonum_derive::{BinaryValue, FromAccess, ObjectHash}; use exonum_merkledb::{ access::{Access, RawAccessMut}, Entry, ListIndex...
code_fim
hard
{ "lang": "rust", "repo": "zhang-zw123/vchain-demo", "path": "/vchain-exonum/src/schema.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.block_headers .get(&id) .context("failed to read block header")? .to_vchain_type() } fn read_block_data(&self, id: IdType) -> Result<vchain::BlockData> { self.block_data .get(&id) .context("failed to read block data")...
code_fim
hard
{ "lang": "rust", "repo": "zhang-zw123/vchain-demo", "path": "/vchain-exonum/src/schema.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn sections() { let wikipedia = w(); let page = wikipedia.page_from_title("Bikeshedding".to_owned()); assert_eq!( page.get_sections().unwrap(), vec![ "Argument".to_owned(), "Examples".to_owned(), ...
code_fim
hard
{ "lang": "rust", "repo": "seppo0010/wikipedia-rs", "path": "/tests/integration.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seppo0010/wikipedia-rs path: /tests/integration.rs extern crate wikipedia; #[cfg(feature = "http-client")] mod tests { use wikipedia::Wikipedia; use wikipedia::http; use std::collections::HashSet; fn w() -> Wikipedia<http::default::Client> { Wikipedia::default() } ...
code_fim
hard
{ "lang": "rust", "repo": "seppo0010/wikipedia-rs", "path": "/tests/integration.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut wikipedia = w(); wikipedia.links_results = "3".to_owned(); let page = wikipedia.page_from_title("Argentina".to_owned()); let links = page.get_links().unwrap(); let mut c = 0; let mut set = HashSet::new(); for r in links { c += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "seppo0010/wikipedia-rs", "path": "/tests/integration.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let result = client .post(&url) .header("x-api-token", cfg.token.clone()) .header("Content-Type", "application/json") .body(act_str) .send() .map_err(|e| e.to_string()); match result { Ok(result) => { if result.status().as_u16() >...
code_fim
hard
{ "lang": "rust", "repo": "shibh308/procon2020-comp", "path": "/src/api/request.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let act_str = "{\"actions\":[".to_string() + &*acts .iter() .zip(&team_data.agent_id) .map(|(act, id)| { let (x, y, type_str) = match act { Act::StayAct => (0, 0, "stay"), Act::PutAct(p) => (p.x + 1, p....
code_fim
hard
{ "lang": "rust", "repo": "shibh308/procon2020-comp", "path": "/src/api/request.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }