text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> Some(Object { endian, data, dwarf, syms, }) } pub fn section(&self, _: &Stash, name: &str) -> Option<&'a [u8]> { let name = name.as_bytes(); let dwarf = self.dwarf?; let section = dwarf.into_iter().find(|secti...
code_fim
hard
{ "lang": "rust", "repo": "gabrielesvelto/api-daemon", "path": "/third-party/backtrace/src/symbolize/gimli/macho.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use crate::*; #[test] fn test_145() { assert_eq!(Solution::postorder_traversal(tree![1,null,2,3]), vec![3,2,1]); assert_eq!(Solution::postorder_traversal(tree![]), vec![]); } }<|fim_prefix|>// repo: Frezc/leetcode-solutions path:...
code_fim
hard
{ "lang": "rust", "repo": "Frezc/leetcode-solutions", "path": "/src/n0145_binary_tree_postorder_traversal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Frezc/leetcode-solutions path: /src/n0145_binary_tree_postorder_traversal.rs /** * [145] Binary Tree Postorder Traversal * * Given a binary tree, return the postorder traversal of its nodes' values. * * Example: * * * Input: [1,null,2,3] * 1 * \ * 2 * / * 3 * ...
code_fim
hard
{ "lang": "rust", "repo": "Frezc/leetcode-solutions", "path": "/src/n0145_binary_tree_postorder_traversal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use refs::Graph; let mut g: Graph<String> = Graph::new(); let root = g.add_root_node(String::from("root")); let n1 = g.add_child(root.clone(), String::from("n1")); let n2 = g.add_child(root.clone(), String::from("n2")); let n3 = g.add_child(n2.clone(), Stri...
code_fim
hard
{ "lang": "rust", "repo": "danigm/rust-graph-example", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut c = g.child(root.clone(), 0); assert_eq!("n1", c.borrow().value); c = g.child(root.clone(), 1); assert_eq!("n2", c.borrow().value); c = g.child(n2.clone(), 0); assert_eq!("n3", c.borrow().value); c = g.child(n3.clone(), 0); assert_eq!...
code_fim
hard
{ "lang": "rust", "repo": "danigm/rust-graph-example", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danigm/rust-graph-example path: /src/lib.rs pub mod pointers; pub mod hm; pub mod refs; #[cfg(test)] mod tests { // Test graph with cycles // // [root] --> [n1] // ^ | // | +-> [n2] --> [n3] // | | // ------------------+ #[test] ...
code_fim
hard
{ "lang": "rust", "repo": "danigm/rust-graph-example", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if vec.is_empty() { drops.to_string() } else { vec.join("") } }<|fim_prefix|>// repo: jca/exercism path: /rust/raindrops/src/lib.rs const SOUNDS: [(u32, &str); 3] = [(3, "Pling"), (5, "Plang"), (7, "Plong")]; <|fim_middle|>// Plops away depending on the dividability of the in...
code_fim
hard
{ "lang": "rust", "repo": "jca/exercism", "path": "/rust/raindrops/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jca/exercism path: /rust/raindrops/src/lib.rs const SOUNDS: [(u32, &str); 3] = [(3, "Pling"), (5, "Plang"), (7, "Plong")]; <|fim_suffix|> if vec.is_empty() { drops.to_string() } else { vec.join("") } }<|fim_middle|>// Plops away depending on the dividability of the in...
code_fim
hard
{ "lang": "rust", "repo": "jca/exercism", "path": "/rust/raindrops/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn list(&self, name: String) -> Result<&Item, String> { if name.to_lowercase() == "all".to_string() { for itm in self.items_list.iter() { println!("Available items in shop : {:#?}", itm); } } let found = s...
code_fim
hard
{ "lang": "rust", "repo": "lusamreth/rust-learning", "path": "/src/structure.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lusamreth/rust-learning path: /src/structure.rs #![allow(dead_code)] use rand::Rng; // hashmap pub fn run() -> f64 { struct Color(i32, i32, i32); let _white = Color(255, 255, 255); // println!("{:?}",_white); coordinate_plane(); let point_array = rand_point(20, 1000, Lopt::Ma...
code_fim
hard
{ "lang": "rust", "repo": "lusamreth/rust-learning", "path": "/src/structure.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = money * rate; println!("{}$ exchange to {}", money, result); return result; } match curr { Currency::Reil => calc(money, 4000.0), Currency::Euro => calc(money, 0.92), Currency::Dollar(DollarCountries) => { use DollarCountries...
code_fim
hard
{ "lang": "rust", "repo": "lusamreth/rust-learning", "path": "/src/structure.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut f = File::open("su1m.txt")?; let mut s = String::new(); f.read_to_string(&mut s)?; let mut sum = 0; for c in s.lines() { sum += c.parse::<i32>()?; } println!("{}", sum); Ok(sum) } /*mod tests { use thiserror::Error; use std::{io, num}; use std:...
code_fim
hard
{ "lang": "rust", "repo": "Liu-WeiHu/learn-rust", "path": "/error/learn-error/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Liu-WeiHu/learn-rust path: /error/learn-error/src/main.rs //mod origin; //mod refact1; //mod refact2; //mod refact3; //mod refact4; use std::fs::File; use std::io::Read; use std::{io, num}; use thiserror::Error; #[derive(Error, Debug)] enum MyError { #[error("IO 异常拉 {0}")] Io(#[from] i...
code_fim
hard
{ "lang": "rust", "repo": "Liu-WeiHu/learn-rust", "path": "/error/learn-error/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", Solution::get_row(0)); println!("{:?}", Solution::get_row(1)); println!("{:?}", Solution::get_row(2)); println!("{:?}", Solution::get_row(3)); println!("{:?}", Solution::get_row(4)); } struct Solution; impl Solution { // pub fn get_row(row_index: i32) -> Vec<i32> ...
code_fim
medium
{ "lang": "rust", "repo": "yqy7/rustleetcode", "path": "/src/bin/t119.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yqy7/rustleetcode path: /src/bin/t119.rs // 119. 杨辉三角 II // 给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行。 // // // // 在杨辉三角中,每个数是它左上方和右上方的数的和。 // // 示例: // // 输入: 3 // 输出: [1,3,3,1] // 进阶: // // 你可以优化你的算法到 O(k) 空间复杂度吗? // // 来源:力扣(LeetCode) // 链接:https://leetcode-cn.com/problems/pascals-triangle-ii // 著作权归...
code_fim
hard
{ "lang": "rust", "repo": "yqy7/rustleetcode", "path": "/src/bin/t119.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avitex/rust-public-ip path: /src/error.rs use std::error::Error as StdError; use std::fmt::Debug; use std::net::AddrParseError; use std::str::Utf8Error; use thiserror::Error; #[cfg(feature = "dns-resolver")] use crate::dns; #[cfg(feature = "http-resolver")] use crate::http; /// An error produ...
code_fim
hard
{ "lang": "rust", "repo": "avitex/rust-public-ip", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<Utf8Error> for Error { fn from(_: Utf8Error) -> Self { Self::Addr } } impl From<AddrParseError> for Error { fn from(_: AddrParseError) -> Self { Self::Addr } }<|fim_prefix|>// repo: avitex/rust-public-ip path: /src/error.rs use std::error::Error as StdError; use...
code_fim
medium
{ "lang": "rust", "repo": "avitex/rust-public-ip", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut min = std::i32::MAX; for point in intersections.iter() { if point[0] == 0 && point[1] == 0 { continue; } let dist = get_manattan_distance([0,0], *point); println!("{:?} {}", point, dist); if dist < min { min = dist; ...
code_fim
hard
{ "lang": "rust", "repo": "a-harvie/advent-2019", "path": "/day_03/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let f = File::open("input/input.txt").unwrap(); let reader = BufReader::new(f); let mut values1 = Vec::new(); let mut values2 = Vec::new(); for (index,line) in reader.lines().enumerate() { if index == 0 { values1 = line.unwrap().split(",").collect(); } ...
code_fim
hard
{ "lang": "rust", "repo": "a-harvie/advent-2019", "path": "/day_03/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: a-harvie/advent-2019 path: /day_03/src/main.rs use std::io::{BufRead, BufReader}; use std::fs::File; fn main() { let tests = [ [ vec!["R8","U5","L5","D3"], vec!["U7","R6","D4","L4"], vec!["6"] ], [ vec!["R75","D30",...
code_fim
hard
{ "lang": "rust", "repo": "a-harvie/advent-2019", "path": "/day_03/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PsichiX/Oxygengine path: /engine/ha-renderer/src/constants.rs pub mod material_uniforms { pub const MODEL_MATRIX_NAME: &str = "model"; pub const VIEW_MATRIX_NAME: &str = "view"; pub const PROJECTION_MATRIX_NAME: &str = "projection"; pub const TI<|fim_suffix|>OFFSET_NAME: &str = "...
code_fim
medium
{ "lang": "rust", "repo": "PsichiX/Oxygengine", "path": "/engine/ha-renderer/src/constants.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>OFFSET_NAME: &str = "mainImageOffset"; pub const MAIN_IMAGE_SIZE_NAME: &str = "mainImageSize"; }<|fim_prefix|>// repo: PsichiX/Oxygengine path: /engine/ha-renderer/src/constants.rs pub mod material_uniforms { pub const MODEL_MATRIX_NAME: &str = "model"; pub const VIEW_MATRIX_NAME: &str = "vie...
code_fim
medium
{ "lang": "rust", "repo": "PsichiX/Oxygengine", "path": "/engine/ha-renderer/src/constants.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: K4rakara/utils path: /gui/launcher/src/main.rs #[macro_use] pub extern crate lazy_static; pub extern crate cairo; pub extern crate chrono; pub extern crate crossbeam; pub extern crate clap; pub extern crate log; pub extern crate gdk; pub extern crate gio; pub extern crate glib; pub extern crate ...
code_fim
hard
{ "lang": "rust", "repo": "K4rakara/utils", "path": "/gui/launcher/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Create state. let mut state = State::new(&app); // Load CSS. let provider = gtk::CssProvider::new(); provider.load_from_data(CSS.as_bytes()).expect("\n\nFailed to load CSS.\n\n"); gtk::StyleContext::add_provider_for_screen( &gdk::Screen::get_...
code_fim
hard
{ "lang": "rust", "repo": "K4rakara/utils", "path": "/gui/launcher/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timokae/data-node path: /src/backend_service.rs use crate::logger; use crate::models; use crate::storage; use models::Package; use storage::Storage; use serde::Deserialize; use std::net::{IpAddr::V4, Ipv4Addr, SocketAddr}; use std::sync::Arc; use tokio::sync::mpsc; use warp::Filter; /// The B...
code_fim
hard
{ "lang": "rust", "repo": "timokae/data-node", "path": "/src/backend_service.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn handle_lookup(hash: String, storage: Arc<Storage>) -> warp::reply::Json { let h = hash.parse::<u64>().unwrap(); match storage.get(h) { Some(value) => warp::reply::json(&value), None => match storage.get_foreign(h) { Some(value) => warp::reply::json(&value), ...
code_fim
hard
{ "lang": "rust", "repo": "timokae/data-node", "path": "/src/backend_service.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jimblandy/rbattle path: /src/protocol.rs //! The rbattle game protocol. //! //! All hosts participating in an rbattle game have a complete copy of the //! state, and the algorithm for evolving the state from one moment to the next //! is strictly deterministic. //! //! Every effect the player ca...
code_fim
hard
{ "lang": "rust", "repo": "jimblandy/rbattle", "path": "/src/protocol.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// This impl allows `Scheduler` to send the actions collected for a turn to the /// local game. impl Notifier for mpsc::Sender<CollectedActions> { fn notify(self: Box<Self>, turn: CollectedActions) { self.send(turn) .expect("mpsc notifier receiver died"); } } impl Service for...
code_fim
hard
{ "lang": "rust", "repo": "jimblandy/rbattle", "path": "/src/protocol.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_client(addr: SocketAddr) -> Result<Participant, Error> { let stream = TcpStream::connect(addr)?; stream.set_nodelay(true)?; let (sender, receiver) = mpsc::channel(); fn setup(reader: &mut BufReader<&TcpStream>, writer: &mut BufWriter<&TcpStream>) ...
code_fim
hard
{ "lang": "rust", "repo": "jimblandy/rbattle", "path": "/src/protocol.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// The iterator is finished. /// /// A iterator finishes either when it has collected `num_results` results /// from the closest peers (not counting those that failed or are unresponsive) /// or because the iterator ran out of peers that have not yet delivered /// results (or fail...
code_fim
hard
{ "lang": "rust", "repo": "libp2p/rust-libp2p", "path": "/protocols/kad/src/query/peers/closest.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libp2p/rust-libp2p path: /protocols/kad/src/query/peers/closest.rs self.state = State::Finished; return PeersIterState::Finished; } } } PeerState::NotContacted => { if !a...
code_fim
hard
{ "lang": "rust", "repo": "libp2p/rust-libp2p", "path": "/protocols/kad/src/query/peers/closest.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libp2p/rust-libp2p path: /protocols/kad/src/query/peers/closest.rs I: IntoIterator<Item = PeerId>, { if let State::Finished = self.state { return false; } let key = Key::from(*peer); let distance = key.distance(&self.target); // Mark ...
code_fim
hard
{ "lang": "rust", "repo": "libp2p/rust-libp2p", "path": "/protocols/kad/src/query/peers/closest.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunjay/lion path: /src/lib.rs #![recursion_limit="128"] <|fim_suffix|>pub mod ast; pub mod parser; pub mod unit_graph; pub mod interpreter; pub mod symbols; pub mod canonical; pub mod ir; pub mod display_string;<|fim_middle|>#[cfg(test)] #[macro_use] extern crate pretty_assertions;
code_fim
easy
{ "lang": "rust", "repo": "sunjay/lion", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod ast; pub mod parser; pub mod unit_graph; pub mod interpreter; pub mod symbols; pub mod canonical; pub mod ir; pub mod display_string;<|fim_prefix|>// repo: sunjay/lion path: /src/lib.rs #![recursion_limit="128"] <|fim_middle|>#[cfg(test)] #[macro_use] extern crate pretty_assertions;
code_fim
easy
{ "lang": "rust", "repo": "sunjay/lion", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /crates/jit-debug/src/perf_jitdump.rs //! Support for jitdump files which can be used by perf for profiling jitted code. //! Spec definitions for the output format is as described here: //! <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/t...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/crates/jit-debug/src/perf_jitdump.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the next code index pub fn next_code_index(&mut self) -> u64 { let code_index = self.code_index; self.code_index += 1; code_index } pub fn write_file_header(&mut self) -> io::Result<()> { let header = FileHeader { timestamp: self.get...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/crates/jit-debug/src/perf_jitdump.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> fn set_reader_commander(&mut self, commander: mio_channel::SyncSender<ReaderCommand>) { self.reader_command = commander; } }<|fim_prefix|>// repo: timsaucer/RustDDS path: /src/test/datareader_util.rs use serde::de::DeserializeOwned; use mio_extras::channel as mio_channel; use crate::{ dds::{Wi...
code_fim
hard
{ "lang": "rust", "repo": "timsaucer/RustDDS", "path": "/src/test/datareader_util.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timsaucer/RustDDS path: /src/test/datareader_util.rs use serde::de::DeserializeOwned; use mio_extras::channel as mio_channel; use crate::{ dds::{With_Key_DataReader as DataReader}, dds::error::StatusChange, dds::traits::Keyed, serialization::DeserializerAdapter, dds::with_key::ReaderC...
code_fim
hard
{ "lang": "rust", "repo": "timsaucer/RustDDS", "path": "/src/test/datareader_util.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "macros")] pub use crate::macros::*;<|fim_prefix|>// repo: Unoqwy/polecen path: /polecen/src/lib.rs pub mod arguments; pub mod command; #[cfg(feature = "macros")] pub mod macros; <|fim_middle|>pub use async_trait::async_trait; pub use polecen_macros::*;
code_fim
medium
{ "lang": "rust", "repo": "Unoqwy/polecen", "path": "/polecen/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Unoqwy/polecen path: /polecen/src/lib.rs pub mod arguments; pub mod command; <|fim_suffix|>#[cfg(feature = "macros")] pub use crate::macros::*;<|fim_middle|>#[cfg(feature = "macros")] pub mod macros; pub use async_trait::async_trait; pub use polecen_macros::*;
code_fim
medium
{ "lang": "rust", "repo": "Unoqwy/polecen", "path": "/polecen/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Unoqwy/polecen path: /polecen/src/lib.rs pub mod arguments; pub mod command; <|fim_suffix|>pub use async_trait::async_trait; pub use polecen_macros::*; #[cfg(feature = "macros")] pub use crate::macros::*;<|fim_middle|>#[cfg(feature = "macros")] pub mod macros;
code_fim
easy
{ "lang": "rust", "repo": "Unoqwy/polecen", "path": "/polecen/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> gradient.positions.sort_unstable_by(|a, b| a.0.partial_cmp(&b.0).unwrap()); send_fill_message(gradient) }; if !skip_separator { widgets.push(Separator::new(SeparatorType::Related).widget_holder()); } widgets.push(IconButton::new("Add", 16).tooltip("Add a gradient stop after this").on_up...
code_fim
hard
{ "lang": "rust", "repo": "GraphiteEditor/Graphite", "path": "/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut layout = vec![node_gradient_type(gradient)]; layout.extend((0..gradient.positions.len()).map(|pos| node_gradient_color(gradient, pos))); layout.push(LayoutGroup::Row { widgets: vec![ TextLabel::new("").widget_holder(), Separator::new(SeparatorType::Unrelated).widget_ho...
code_fim
hard
{ "lang": "rust", "repo": "GraphiteEditor/Graphite", "path": "/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GraphiteEditor/Graphite path: /editor/src/messages/portfolio/document/properties_panel/utility_functions.rs ction_transform(layer, persistent_data), fill_layout, node_section_stroke(&shape.style.stroke().unwrap_or_default()), ] } else { vec![node_section_transform(layer, per...
code_fim
hard
{ "lang": "rust", "repo": "GraphiteEditor/Graphite", "path": "/editor/src/messages/portfolio/document/properties_panel/utility_functions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use self::State::*; let mut last_iter = multipeek(last.iter()); let mut x = 0i64; let mut neighborhood = 0u8; loop { if neighborhood == 0 { let next = last_iter.peek(); if next.is_none() { break; } else { x = **next.unwrap() - 2; } last_iter.reset_peek(); } if last_iter....
code_fim
hard
{ "lang": "rust", "repo": "Naalunth/aoc_2018", "path": "/src/year2018/day12.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Naalunth/aoc_2018 path: /src/year2018/day12.rs type GeneratorOut = Input; type PartIn = GeneratorOut; use itertools::multipeek; use nom::types::CompleteStr; use std::convert::AsRef; #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq)] enum State { Dead = 0, Alive = 1, } #[derive(Debug, Clon...
code_fim
hard
{ "lang": "rust", "repo": "Naalunth/aoc_2018", "path": "/src/year2018/day12.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Environment { /// Allow access to the entire environment. pub fn all() -> Self { let allow = gix_sec::Permission::Allow; Environment { xdg_config_home: allow, home: allow, git_prefix: allow, ssh_prefix: allow, http_tr...
code_fim
hard
{ "lang": "rust", "repo": "Byron/gitoxide", "path": "/gix/src/open/permissions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Allow loading attributes that are local to the git repository. pub fn isolated() -> Self { Attributes { git_binary: false, system: false, git: false, } } } impl Default for Attributes { fn default() -> Self { Self::all() ...
code_fim
hard
{ "lang": "rust", "repo": "Byron/gitoxide", "path": "/gix/src/open/permissions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Byron/gitoxide path: /gix/src/open/permissions.rs //! Various permissions to define what can be done when operating a [`Repository`][crate::Repository]. use gix_sec::Trust; use crate::open::Permissions; /// Configure from which sources git configuration may be loaded. /// /// Note that configu...
code_fim
hard
{ "lang": "rust", "repo": "Byron/gitoxide", "path": "/gix/src/open/permissions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(a.utf8()? .into_iter() .zip(b.utf8()?) .map(|(lhs, rhs)| hamming_distance_strs(lhs, rhs)) .collect()) } /// Compute the hamming distance between 2 string values. fn hamming_distance_strs(a: Option<&str>, b: Option<&str>) -> Option<u32> { match (a, b) { (...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/examples/python_rust_compiled_function/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pola-rs/polars path: /examples/python_rust_compiled_function/src/lib.rs mod ffi; use polars::prelude::*; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; #[pyfunction] fn hamming_distance(series_a: &PyAny, series_b: &PyAny) -> PyResult<PyObject> { <|fim_suffix|>/// This function itera...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/examples/python_rust_compiled_function/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// This function iterates over 2 `Utf8Chunked` arrays and computes the hamming distance between the values . fn hamming_distance_impl(a: &Series, b: &Series) -> PolarsResult<UInt32Chunked> { Ok(a.utf8()? .into_iter() .zip(b.utf8()?) .map(|(lhs, rhs)| hamming_distance_strs(lhs,...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/examples/python_rust_compiled_function/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lillo42/rust-sample path: /06-enum/enums/src/main.rs use std::fmt; enum IpAddrKind { V4, V6 } #[derive(Debug)] enum IpAddrKind2 { V4(u8, u8, u8, u8), V6(String) } enum Coin { Penny, Nickel, Dime, Quarter, } enum Messages { Quit, Move { x: i32, y: i32}...
code_fim
hard
{ "lang": "rust", "repo": "lillo42/rust-sample", "path": "/06-enum/enums/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl IpAddrKind2 { fn to_string(&self) -> String { match self { IpAddrKind2::V4(x, y, z, w) => format!("is address {}.{}.{}.{} and IP Kind {}", x, y, z, w, String::from("V4")), IpAddrKind2::V6(address) => format!("is address {} and IP Kind {}", address, String::from("V...
code_fim
hard
{ "lang": "rust", "repo": "lillo42/rust-sample", "path": "/06-enum/enums/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let home2 = IpAddrKind2::V4(127,0,0,1); let loop_back2 = IpAddrKind2::V6(String::from(":1")); println!("home2 is {}", home2.to_string()); println!("loop_back2 is {}", loop_back2.to_string()); let m = Messages::Write(String::from("hello")); m.call(); let some_number = So...
code_fim
hard
{ "lang": "rust", "repo": "lillo42/rust-sample", "path": "/06-enum/enums/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (1..=num).fold(1, | prod, elem | prod * elem) } fn main() { //let res = triangle(100); //println!("product =={}", res); let s = "Hello world!"; let cow : Cow<str> = Cow::Owned(String::from(s)); }<|fim_prefix|>// repo: nicholasnjihian/All-my-rust-code-thus-far path: /trial_code_snipp...
code_fim
easy
{ "lang": "rust", "repo": "nicholasnjihian/All-my-rust-code-thus-far", "path": "/trial_code_snippets/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nicholasnjihian/All-my-rust-code-thus-far path: /trial_code_snippets/src/main.rs #![allow(dead_code)] use std::borrow::Cow; fn triangle(num : i32) -> i32 { <|fim_suffix|> //let res = triangle(100); //println!("product =={}", res); let s = "Hello world!"; let cow : Cow<str> = Cow...
code_fim
medium
{ "lang": "rust", "repo": "nicholasnjihian/All-my-rust-code-thus-far", "path": "/trial_code_snippets/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: camshaft/bolero path: /bolero-generator/src/std/mod.rs #![allow(clippy::implicit_hasher)] use crate::{alloc_generators::CollectionGenerator, Driver, TypeGenerator, ValueGenerator}; use core::{hash::Hash, ops::RangeInclusive}; use std::{ collections::{HashMap, HashSet}, sync::Mutex, }; ...
code_fim
hard
{ "lang": "rust", "repo": "camshaft/bolero", "path": "/bolero-generator/src/std/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: TypeGenerator> TypeGenerator for Mutex<T> { fn generate<D: Driver>(driver: &mut D) -> Option<Self> { Some(Self::new(driver.gen()?)) } fn mutate<D: Driver>(&mut self, driver: &mut D) -> Option<()> { if let Ok(value) = self.get_mut() { value.mutate(driver)?; ...
code_fim
hard
{ "lang": "rust", "repo": "camshaft/bolero", "path": "/bolero-generator/src/std/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Prints an error raised by an in-place FFT algorithm's `process_inplace` method // Marked cold and inline never to keep all formatting code out of the many monomorphized process_inplace methods #[cold] #[inline(never)] pub fn dct_error_inplace( actual_len: usize, actual_scratch: usize, expec...
code_fim
hard
{ "lang": "rust", "repo": "ejmahler/rust_dct", "path": "/src/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ejmahler/rust_dct path: /src/common.rs use rustfft::num_traits::FloatConst; use rustfft::FftNum; /// Generic floating point number pub trait DctNum: FftNum + FloatConst { fn half() -> Self; fn two() -> Self; } impl<T: FftNum + FloatConst> DctNum for T { fn half() -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "ejmahler/rust_dct", "path": "/src/common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: phaylon/html5-fuser path: /src/modifier/select/subselect_any.rs use event; use select; use transform; use builder; use super::{ SelectAny, SelectAnyOnce, BuildSubElementStream, SelectContent, CurrentContent, }; /// Select a substream at any level in the current elements children. pub stru...
code_fim
hard
{ "lang": "rust", "repo": "phaylon/html5-fuser", "path": "/src/modifier/select/subselect_any.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn build_once(self, stream: transform::Api<CurrentContent<S>>) -> transform::Api<Self::Stream> { transform::Api::pack(SelectAny::new(stream.unpack(), self.selector, self.select_builder)) } } struct BuilderOnce<M, B> { select_builder: B, selector: M, } impl<S, M, B> builder::B...
code_fim
hard
{ "lang": "rust", "repo": "phaylon/html5-fuser", "path": "/src/modifier/select/subselect_any.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Solution::minimum_total(Vec::new()), 0); } #[bench] fn bench(b: &mut test::Bencher) { b.iter(|| { Solution::minimum_total(vec![vec![2], vec![3, 4], vec![5, 6, 7], vec![4, 1, 8, 3]]); }); } }<|fim_prefix|>// repo: COLDTURNIP/raphanus_leetcode ...
code_fim
hard
{ "lang": "rust", "repo": "COLDTURNIP/raphanus_leetcode", "path": "/rust/src/p120.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: COLDTURNIP/raphanus_leetcode path: /rust/src/p120.rs /* Problem 120. Triangle ===================== https://leetcode.com/problems/triangle/ Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the follo...
code_fim
hard
{ "lang": "rust", "repo": "COLDTURNIP/raphanus_leetcode", "path": "/rust/src/p120.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>r ( bytes : Vec < u8 > ) - > io : : Result < String > { let mut gz = read : : GzDecoder : : new ( & bytes [ . . ] ) ; let mut s = String : : new ( ) ; gz . read_to_string ( & mut s ) ? ; Ok ( s ) }<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/flate2/examples/gzdecoder-read.rs...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/flate2/examples/gzdecoder-read.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/flate2/examples/gzdecoder-read.rs extern crate flate2 ; use flate2 : : write : : GzEncoder ; use flate2 : : { read Compression } ; use std : : io ; use std : : io : : prelude : : * ; / / Compress a sample string and print it after<|fim_suffix|>...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/flate2/examples/gzdecoder-read.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> if body.is_empty().expect("no length on response body") { let new_body = json!({ "error": { "status_code": status.to_string(), "message": "Something went wrong", } ...
code_fim
hard
{ "lang": "rust", "repo": "autocatalytic/witter", "path": "/backend/src/middlewares.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: autocatalytic/witter path: /backend/src/middlewares.rs // use crate::State; // use futures::future::BoxFuture; use serde_json::json; // use std::future::Future; // use std::pin::Pin; // use tide::http::headers::HeaderValue; // use tide::http::{headers, Method, StatusCode}; // use tide::security:...
code_fim
hard
{ "lang": "rust", "repo": "autocatalytic/witter", "path": "/backend/src/middlewares.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input = r#"{ "channel_id": "2", "guild_id": "1", "member": { "deaf": false, "hoisted_role": "4", "joined_at": "2020-01-01T00:00:00.000000+00:00", "mute": false, "nick": "typing", "roles": ["4"], ...
code_fim
hard
{ "lang": "rust", "repo": "SuperiorJT/twilight", "path": "/model/benches/deserialization.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SuperiorJT/twilight path: /model/benches/deserialization.rs use criterion::{criterion_group, criterion_main, Criterion}; use serde::de::DeserializeSeed; use serde_json::Deserializer; use twilight_model::{ channel::Reaction, gateway::{ event::GatewayEventDeserializer, pay...
code_fim
hard
{ "lang": "rust", "repo": "SuperiorJT/twilight", "path": "/model/benches/deserialization.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> let enabled = ["good", "bad", "ugly"]; let many_features = Expression::parse( r#"all(feature = "good", feature = "bad", feature = "ugly", not(feature = "nope"))"#, ) .unwrap(); assert!(many_features.eval(|pred| { match pred { Predicate::Feature(name) => en...
code_fim
hard
{ "lang": "rust", "repo": "EmbarkStudios/cfg-expr", "path": "/tests/eval.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EmbarkStudios/cfg-expr path: /tests/eval.rs use cfg_expr::{ expr::{Predicate, TargetMatcher}, targets::{get_builtin_target_by_triple, ALL_BUILTINS as all}, Expression, TargetPredicate, }; struct Target { builtin: &'static cfg_expr::targets::TargetInfo, #[cfg(feature = "targe...
code_fim
hard
{ "lang": "rust", "repo": "EmbarkStudios/cfg-expr", "path": "/tests/eval.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Set the authority development account for a node in validator mode e.g. --alice. pub fn with_authority(&mut self, account: AccountKeyring) -> &mut Self { self.authority = Some(account); self } /// Spawn the substrate node at the given path, and wait for RPC to be initi...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/ink", "path": "/crates/e2e/src/node_proc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> BufReader::new(r) .lines() .find_map(|line| { let line = line.expect("failed to obtain next line from stdout for port discovery"); // does the line contain our port (we expect this specific output from // substrate). let ...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/ink", "path": "/crates/e2e/src/node_proc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paritytech/ink path: /crates/e2e/src/node_proc.rs // Copyright (C) Parity Technologies (UK) Ltd. // // 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://w...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/ink", "path": "/crates/e2e/src/node_proc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub output_path: String, pub manual: String }<|fim_prefix|>// repo: AlexanderMattheis/filter path: /src/system/extracted_arguments.rs pub struct ExtractedArguments { pub input_path: String, pub reference_path: String, <|fim_middle|>pub filter: String, pub params: String,
code_fim
easy
{ "lang": "rust", "repo": "AlexanderMattheis/filter", "path": "/src/system/extracted_arguments.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexanderMattheis/filter path: /src/system/extracted_arguments.rs pub struct ExtractedArguments { pub input_pa<|fim_suffix|>pub output_path: String, pub manual: String }<|fim_middle|>th: String, pub reference_path: String, pub filter: String, pub params: String,
code_fim
medium
{ "lang": "rust", "repo": "AlexanderMattheis/filter", "path": "/src/system/extracted_arguments.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seppo0010/limitd-rs path: /src/protocol/pb/request.rs self.key.set_default(); }; self.key.as_mut().unwrap() } // Take field pub fn take_key(&mut self) -> ::std::string::String { self.key.take().unwrap_or_else(|| ::std::string::String::new()) } ...
code_fim
hard
{ "lang": "rust", "repo": "seppo0010/limitd-rs", "path": "/src/protocol/pb/request.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Param is passed by value, moved pub fn set_key(&mut self, v: ::std::string::String) { self.key = ::protobuf::SingularField::some(v); } // Mutable pointer to the field. // If field is not initialized, it is initialized with default value first. pub fn mut_key(&mut self) ...
code_fim
hard
{ "lang": "rust", "repo": "seppo0010/limitd-rs", "path": "/src/protocol/pb/request.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seppo0010/limitd-rs path: /src/protocol/pb/request.rs { self.method = ::std::option::Option::None; } pub fn has_method(&self) -> bool { self.method.is_some() } // Param is passed by value, moved pub fn set_method(&mut self, v: Request_Method) { self...
code_fim
hard
{ "lang": "rust", "repo": "seppo0010/limitd-rs", "path": "/src/protocol/pb/request.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn features() { is_complete::<NeqPair, usize, (usize, usize)>(); is_complete::<NeqPair<Of<NeqPair>>, usize, ((usize, usize), (usize, usize))>(); } #[test] fn data() { let x: NeqPair = Construct::new(); let ref dim = 4; assert...
code_fim
hard
{ "lang": "rust", "repo": "bvssvni/discrete", "path": "/src/neq_pair.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let pair: Pair<Data> = Construct::new(); if index % 2 == 0 { pair.to_pos(dim, index / 2, pos); } else { pair.to_pos(dim, (index - 1) / 2, pos); let tmp = pos.1; pos.1 = pos.0; pos.0 = tmp; } } } impl<T, U, V> ...
code_fim
hard
{ "lang": "rust", "repo": "bvssvni/discrete", "path": "/src/neq_pair.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bvssvni/discrete path: /src/neq_pair.rs use std::marker::PhantomData; use num::BigUint; use Construct; use Data; use Count; use Of; use ToIndex; use ToPos; use Zero; /// Dimension is natural number, position is (a, b). /// Represents all directional pairs that has not same element for `a` and...
code_fim
hard
{ "lang": "rust", "repo": "bvssvni/discrete", "path": "/src/neq_pair.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Parse for BlockBody { fn parse(_input: &mut TokenStream) -> ParseResult<Self> { todo!() } }<|fim_prefix|>// repo: vangroan/rust-wren-syn path: /src/parsing/block.rs //! Functions and anonymous blocks (stub functions). use super::{expr::Expr, stmt::DefStmt, Parse, ParseResult}; use cr...
code_fim
hard
{ "lang": "rust", "repo": "vangroan/rust-wren-syn", "path": "/src/parsing/block.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vangroan/rust-wren-syn path: /src/parsing/block.rs //! Functions and anonymous blocks (stub functions). use super::{expr::Expr, stmt::DefStmt, Parse, ParseResult}; use crate::lex::TokenStream; pub struct Block { /// Blocks can have zero or one argument. _arg: Option<()>, /// Any def...
code_fim
hard
{ "lang": "rust", "repo": "vangroan/rust-wren-syn", "path": "/src/parsing/block.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> Command::new("bash") .arg("-c") .arg(full_play) .output() .expect("failed to execute process"); //thread::sleep(Duration::new(31, 0)); //thread::spawn(|| { // Command::new("bash") // .arg("-c") // .arg("killall 'vlc'") // ...
code_fim
hard
{ "lang": "rust", "repo": "andreweggleston/HAROLD", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andreweggleston/HAROLD path: /src/main.rs use std::io; use std::io::{BufReader, BufRead, Write, BufWriter}; use std::fs::File; use reqwest; use std::env; use ldap3::{LdapConn, Scope, SearchEntry}; use std::{thread}; use std::time::Duration; use std::process::Command; //TODO: alot fn main() -> s...
code_fim
hard
{ "lang": "rust", "repo": "andreweggleston/HAROLD", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //thread::spawn(|| { // Command::new("bash") // .arg("-c") // .arg("killall 'vlc'") // .output() // .expect("failed to execute process"); //}); //let ar = AccRe...
code_fim
hard
{ "lang": "rust", "repo": "andreweggleston/HAROLD", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self[..] == other } } impl PartialEq<&'_ str> for Ident { fn eq(&self, &other: &&str) -> bool { &self[..] == other } } // FIXME(eddyb) avoid cloning, build ropes, etc. #[derive(Clone, Debug, PartialEq)] pub enum Tok { Newline, Whitespace, Punct(char), Ident(I...
code_fim
hard
{ "lang": "rust", "repo": "eddyb/cprep", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eddyb/cprep path: /src/lib.rs use std::fmt; trait Eat: Iterator + Clone { fn try_eat<T>(&mut self, f: impl FnOnce(&mut Self) -> Option<T>) -> Option<T> { let mut speculative = self.clone(); let r = f(&mut speculative)?; *self = speculative; Some(r) } ...
code_fim
hard
{ "lang": "rust", "repo": "eddyb/cprep", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self[..] == other } } // FIXME(eddyb) avoid cloning, build ropes, etc. #[derive(Clone, Debug, PartialEq)] pub enum Tok { Newline, Whitespace, Punct(char), Ident(Ident), Literal(String), Error(char), } impl fmt::Display for Tok { fn fmt(&self, f: &mut fmt::Formatt...
code_fim
hard
{ "lang": "rust", "repo": "eddyb/cprep", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shuumatsu/log-structured-filesystem path: /src/segment.rs pub struct Summary { inode_num: usize, logical_blk: usize, } <|fim_suffix|>pub struct UsageTable {}<|fim_middle|>impl Summary { pub fn init() -> Self { unimplemented!() } }
code_fim
medium
{ "lang": "rust", "repo": "Shuumatsu/log-structured-filesystem", "path": "/src/segment.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct UsageTable {}<|fim_prefix|>// repo: Shuumatsu/log-structured-filesystem path: /src/segment.rs pub struct Summary { inode_num: usize, logical_blk: usize, } <|fim_middle|>impl Summary { pub fn init() -> Self { unimplemented!() } }
code_fim
medium
{ "lang": "rust", "repo": "Shuumatsu/log-structured-filesystem", "path": "/src/segment.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caibirdme/leetcode_rust path: /src/prob_246.rs use std::collections::HashMap; macro_rules! hashmap { ($( $key: expr => $val: expr ),*) => {{ let mut map = ::std::collections::HashMap::new(); $( map.insert($key, $val); )* map }} } <|fim_suffix|>struct Solutio...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/prob_246.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let test_cases = vec![ ("69", true), ("6889", true), ("3", false), ("6688899", true), ]; for (s, ok) in test_cases { assert_eq!(Solution::is_strobogrammatic(s.to_string()), ok, "s {}", s); } } }<|fim_prefix|>//...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/prob_246.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(IsIntersectingRanges(&x, &y)); assert!(IsIntersectingRanges(&y, &x)); assert!(!IsIntersectingRanges(&x, &z)); assert!(!IsIntersectingRanges(&z, &x)); assert!(IsEmptyRange(&o)); assert!(IsIntersectingRanges(&x, &o)); assert!(!IsIntersectingRanges(&y, &o)); }<|fim_prefix...
code_fim
hard
{ "lang": "rust", "repo": "Kryndex/xvm16", "path": "/src/memory.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kryndex/xvm16 path: /src/memory.rs use num::traits::*; #[derive(Copy, Clone)] pub struct AddressRange<T: PrimInt> { pub base: T, pub size: T, } pub type MemoryRange = AddressRange<u64>; pub type IoRange = AddressRange<u16>; pub fn IsEmptyRange<T: PrimInt> (x: &AddressRange<T>) -> bool...
code_fim
hard
{ "lang": "rust", "repo": "Kryndex/xvm16", "path": "/src/memory.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> for x in &nums { for y in &nums { println!("{}, {}", x, y); } } } // Cubic time complexity // O(n^3) // Exponential time complexity // O(x^n) // extraordinarily rare, and bad // tower of hanoi runs in O(2^n) // Factorial time complexity // O(n!) // absolutely the slo...
code_fim
hard
{ "lang": "rust", "repo": "AJTJ/rust_big_o", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 2..num { if num % i == 0 { return false; } } return true; } // loglinear complexity // O(nlogn) // basically means that "logn" operations occur "n" times // common in recursive sorting algorithms, sorting algorithms using a binary tree, and many other type...
code_fim
hard
{ "lang": "rust", "repo": "AJTJ/rust_big_o", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }