text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>// fmtp_parse_message pub fn fmtp_parse_message<'a>( message: &'a [u8]) -> IResult<&'a[u8], FMTPMessage>{ let _input = message; // Vérification du header do_parse!( message, header: fmtp_parse_header >> data: fmtp_parse_data >> ( FMTPMess...
code_fim
hard
{ "lang": "rust", "repo": "gemini-15/fuzz", "path": "/src/fmtp/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wherethebitsroam/aoc2019 path: /src/day17.rs use crate::intcode::ExitMode; use crate::intcode::Intcode; use std::fs::File; use std::io::BufReader; use std::io::Read; #[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)] struct Point { x: i64, y: i64, } pub fn part1() { let f = File::o...
code_fim
hard
{ "lang": "rust", "repo": "wherethebitsroam/aoc2019", "path": "/src/day17.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn part2() { let f = File::open("day17.txt").expect("file not found"); let mut f = BufReader::new(f); let mut data = String::new(); f.read_to_string(&mut data).expect("failed to read string"); let mut code = Intcode::new(&data); // set into active mode code.set_imm(0, 2); ...
code_fim
hard
{ "lang": "rust", "repo": "wherethebitsroam/aoc2019", "path": "/src/day17.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: corka149/file_join path: /src/join.rs use std::fs::{File, OpenOptions}; use std::io::{self, BufReader, prelude::*}; /// /// Reads a list of files and stores their content /// pub struct FileJoinerReader<'a> { source: &'a [&'a str], target: &'a str, complete_content: Vec<u8>, } impl<'a> F...
code_fim
hard
{ "lang": "rust", "repo": "corka149/file_join", "path": "/src/join.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let files = vec!["test/test1.txt", "test/test2.txt", "test/test3.txt"]; let file_joiner = FileJoinerReader::new(&files, "new_file.txt"); file_joiner.read_all_files().unwrap(); assert!(true); } #[test] fn test_write_output_file() { let files = vec!["test/test1.txt", "test/test2.t...
code_fim
hard
{ "lang": "rust", "repo": "corka149/file_join", "path": "/src/join.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexander-akhmetov/mos path: /src/x86.rs #[inline(always)] pub unsafe fn hlt_loop() -> ! { /// Halts the CPU by executing the `hlt` instruction. /// runs "hlt" instruction forever loop { hlt(); } } #[inline(always)] pub unsafe fn hlt() { /// calls "hlt" instruction ...
code_fim
hard
{ "lang": "rust", "repo": "alexander-akhmetov/mos", "path": "/src/x86.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub unsafe fn read_rax() -> u64 { /// returns RAX register's value let result: u64; asm!("mov $0, rax" : "=r"(result) // output : // no input :: "volatile", "intel", // options ); result } pub unsafe fn read_cr3() -> u64 { ...
code_fim
hard
{ "lang": "rust", "repo": "alexander-akhmetov/mos", "path": "/src/x86.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub unsafe fn read_cr2() -> u64 { /// returns CR2 register's value let result: u64; asm!("mov $0, cr2" : "=r"(result) // output : // no input :: "volatile", "intel", // options ); result }<|fim_prefix|>// repo: alexander-akhm...
code_fim
hard
{ "lang": "rust", "repo": "alexander-akhmetov/mos", "path": "/src/x86.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ndob/kbchatbox path: /src/keybase.rs dStdin, ChildStdout, Command, Stdio}; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering::SeqCst; use std::sync::mpsc; use std::sync::mpsc::{Receiver, Sender}; use std::sync::Arc; use std::thread; use std::thread::JoinHandle; #[derive(Partial...
code_fim
hard
{ "lang": "rust", "repo": "ndob/kbchatbox", "path": "/src/keybase.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let topic_name = match c["channel"]["topic_name"].as_str() { Some(name) => name.to_string(), None => "".to_string(), }; let id = match c["id"].as_str() { Some(id) => id.to_string(), None => return Err(Keyb...
code_fim
hard
{ "lang": "rust", "repo": "ndob/kbchatbox", "path": "/src/keybase.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ndob/kbchatbox path: /src/keybase.rs ite}; use std::process::{ChildStdin, ChildStdout, Command, Stdio}; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering::SeqCst; use std::sync::mpsc; use std::sync::mpsc::{Receiver, Sender}; use std::sync::Arc; use std::thread; use std::thread::...
code_fim
hard
{ "lang": "rust", "repo": "ndob/kbchatbox", "path": "/src/keybase.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let self_c = self.clone(); let rhs_c = rhs.clone(); CayleyPair { a: self.a * rhs.a - rhs.b.conjugate() * self.b, b: rhs_c.b * self_c.a + self_c.b * rhs_c.a.conjugate(), } } } impl<T> MulAssign<Self> for CayleyPair<T> where Self: Clone + Mul<...
code_fim
hard
{ "lang": "rust", "repo": "vlad9486/gal", "path": "/src/cayley.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vlad9486/gal path: /src/cayley.rs use core::ops::{Add, AddAssign, Neg, Sub, SubAssign, Mul, MulAssign}; use core::fmt; #[derive(Clone, Eq, PartialEq)] pub struct CayleyPair<T> { a: T, b: T, } impl<T> fmt::Debug for CayleyPair<T> where T: fmt::Debug, { fn fmt(&self, f: &mut fmt:...
code_fim
hard
{ "lang": "rust", "repo": "vlad9486/gal", "path": "/src/cayley.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let result = verify_paillier("{\"secret_key\":\"4794853ce9e44b4c7a69c6a3b87db077f8f910f244bb6b966ba5fed83c9756f1\",\"paillier_pk\":null}", "{\"n\":\"9e2f24f407914eff43b7c7df083c5cc9765c05386485e9e9aa55e7b039290300ba39e86f399e2b338fad4bb34a4d7a7a0cd14fd28503eeebb73ff38e8164616942113afadaeaba525bd4c...
code_fim
hard
{ "lang": "rust", "repo": "Vorticity-Flux/nash-rust", "path": "/mpc-wallet/mpc-wallet-wasm/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vorticity-Flux/nash-rust path: /mpc-wallet/mpc-wallet-wasm/src/lib.rs t_key\":\"4794853ce9e44b4c7a69c6a3b87db077f8f910f244bb6b966ba5fed83c9756f1\",\"paillier_pk\":null}", "{\"n\":\"9e2f24f407914eff43b7c7df083c5cc9765c05386485e9e9aa55e7b039290300ba39e86f399e2b338fad4bb34a4d7a7a0cd14fd28503eeebb73...
code_fim
hard
{ "lang": "rust", "repo": "Vorticity-Flux/nash-rust", "path": "/mpc-wallet/mpc-wallet-wasm/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vorticity-Flux/nash-rust path: /mpc-wallet/mpc-wallet-wasm/src/lib.rs aeaba525bd4cfdafc4ddd3b012d3fbcd9f276acbad4379b8b93bc4f4d6ddc0a2b9af36b34771595f0e6cb62987b961d83f49ba6ec4b088a1350b3dbbea3e21033801f6c4b212ecd830b5b81075effd06b47feecf18f3c9093662c918073dd95a525b4f99478512ea3bf085993c9bf65922...
code_fim
hard
{ "lang": "rust", "repo": "Vorticity-Flux/nash-rust", "path": "/mpc-wallet/mpc-wallet-wasm/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonirrings/conway_s_game_of_life path: /src/config_loader.rs use std::fs::File; use std::io::Read; use std::str::FromStr; use regex::Regex; use board::Board; pub fn load_config(path: &String) -> Option<Board> { let mut file = match File::open(path) { Ok(f) => f, _ => retur...
code_fim
hard
{ "lang": "rust", "repo": "jonirrings/conway_s_game_of_life", "path": "/src/config_loader.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ine_bytes.iter() { match *ch { b'*' => cells.push(1), b'.' => cells.push(0), _ => return None, } } } } } if rows == 0 || cols == 0 || gen == 0 || cell...
code_fim
hard
{ "lang": "rust", "repo": "jonirrings/conway_s_game_of_life", "path": "/src/config_loader.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whtcorpsinc/einsteindb-prod path: /interlock/mod.rs // Copyright 2020 WHTCORPS INC. Licensed under Apache-2.0. //! Handles simple SQL query executors locally. //! //! Most MilevaDB read queries are processed by Interlock instead of KV interface. //! By doing so, the CPU of EinsteinDB nodes can ...
code_fim
hard
{ "lang": "rust", "repo": "whtcorpsinc/einsteindb-prod", "path": "/interlock/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// The transaction spacelike_ts of the request pub txn_spacelike_ts: TimeStamp, /// The set of timestamps of locks that can be bypassed during the reading. pub bypass_locks: TsSet, /// The data version to match. If it matches the underlying data version, /// request will not be ...
code_fim
hard
{ "lang": "rust", "repo": "whtcorpsinc/einsteindb-prod", "path": "/interlock/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cojna/contest path: /codeforces/373/b.rs #[allow(unused_imports)] use std::cmp::{min, max}; const RED: isize = 0; const BLACK: isize = 1; fn main(){ let _: i64 = readln(); let cs: Vec<char> = get_line().chars().collect(); println!("{}", min(solve(&cs, RED), solve(&cs, BLACK))); }...
code_fim
hard
{ "lang": "rust", "repo": "cojna/contest", "path": "/codeforces/373/b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); T::read(buf.trim_right()) } trait Read{ fn read(s: &str) -> Self; } macro_rules! read_impl{ ($($t:ty)*) => ($( impl Read for $t { fn read(s: &str) -> $t{ s.parse().unwrap()...
code_fim
hard
{ "lang": "rust", "repo": "cojna/contest", "path": "/codeforces/373/b.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..4 { let p = m.recv_from(&addr); ts1 = p.timestamp(); assert_eq!(p.ty(), packet::Type::Data); total += p.len(); } assert_eq!(total, 5737); let ts2 = t.timestamp(); let mut p = Packet::state(); p.se...
code_fim
hard
{ "lang": "rust", "repo": "carllerche/utp", "path": "/src/test/test_flow.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carllerche/utp path: /src/test/test_flow.rs use super::prelude::*; #[test] fn ramp_up() { const CONNECTION_ID: u16 = 25103; let _ = ::env_logger::init(); ::util::reset_rand(); let (socket, _) = Harness::new(); let mock = Mock::new(); let server = mock.local_addr(); ...
code_fim
hard
{ "lang": "rust", "repo": "carllerche/utp", "path": "/src/test/test_flow.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: udtrokia/Radiancy path: /src/cli/chain.rs use cli::cli::CLI; use num_bigint::{BigInt, Sign}; use blockchain::utils::new_blockchain; use pow::utils::{new_proof_of_work}; use wallet::utils::{hash_pubkey, load_account}; impl CLI { pub fn create_blockchain(self){ let _account = load_acc...
code_fim
hard
{ "lang": "rust", "repo": "udtrokia/Radiancy", "path": "/src/cli/chain.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn print_chain(self) { let mut _bci = self.blockchain.iterator(); println!("\n<-- Start -->\n"); loop { let (_new_bci, _block) = _bci.clone().next(); _bci = _new_bci; println!("\nPrev. hash: {:x}", BigInt::from_bytes_be(Sign:...
code_fim
medium
{ "lang": "rust", "repo": "udtrokia/Radiancy", "path": "/src/cli/chain.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AnonymousAAArdvark/rustlike-dungeons path: /src/object.rs use tcod::colors::*; use tcod::console::*; use serde::{Serialize, Deserialize}; pub(crate) mod object_types; use crate::object_types::*; use crate::{Game, Messages}; /// This is a generic object: the player, a monster, an item, the sta...
code_fim
hard
{ "lang": "rust", "repo": "AnonymousAAArdvark/rustlike-dungeons", "path": "/src/object.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// heal by the given amount, without going over the max pub fn heal(&mut self, amount: i32, game: &Game) { let max_hp = self.max_hp(game); if let Some(ref mut fighter) = self.fighter { fighter.hp += amount; if fighter.hp > max_hp { fighter.h...
code_fim
hard
{ "lang": "rust", "repo": "AnonymousAAArdvark/rustlike-dungeons", "path": "/src/object.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Equip object and show a message about it pub fn equip(&mut self, messages: &mut Messages) { if self.item.is_none() { messages.add( format!("Cant equip {:?} because it's not an Item.", self), RED, ); return; }; ...
code_fim
hard
{ "lang": "rust", "repo": "AnonymousAAArdvark/rustlike-dungeons", "path": "/src/object.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kohbis/leetcode path: /algorithms/0606.construct-string-from-binary-tree/solution.rs // Definition for a binary tree node. // #[derive(Debug, PartialEq, Eq)] // pub struct TreeNode { // pub val: i32, // pub left: Option<Rc<RefCell<TreeNode>>>, // pub right: Option<Rc<RefCell<TreeNode>>>, /...
code_fim
hard
{ "lang": "rust", "repo": "kohbis/leetcode", "path": "/algorithms/0606.construct-string-from-binary-tree/solution.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn helper(root: &Node, s: &mut String) { if let Some(node) = root { let node = node.borrow(); *s += &node.val.to_string(); match (&node.left.is_some(), &node.right.is_some()) { (true, true) => { *s += "("; ...
code_fim
hard
{ "lang": "rust", "repo": "kohbis/leetcode", "path": "/algorithms/0606.construct-string-from-binary-tree/solution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match (&node.left.is_some(), &node.right.is_some()) { (true, true) => { *s += "("; Solution::helper(&node.left, s); *s += ")("; Solution::helper(&node.right, s); *s += ")"; ...
code_fim
hard
{ "lang": "rust", "repo": "kohbis/leetcode", "path": "/algorithms/0606.construct-string-from-binary-tree/solution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SKTT1Ryze/rust-rpg path: /config/src/size.rs //! Size Config //! #![allow(dead_code)] pub const WINDOW_SIZE: u32 = 1024; pub const MAP_BLOCK_SIZE: u32 = 20; pub con<|fim_suffix|>m ObjectSize { CubeSize(u32, u32), SphereSize(u32), }<|fim_middle|>st STEP_LEN: u32 = 10; pub const CUBE_NUM...
code_fim
medium
{ "lang": "rust", "repo": "SKTT1Ryze/rust-rpg", "path": "/config/src/size.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>m ObjectSize { CubeSize(u32, u32), SphereSize(u32), }<|fim_prefix|>// repo: SKTT1Ryze/rust-rpg path: /config/src/size.rs //! Size Config //! #![allow(dead_code)] pub const WINDOW_<|fim_middle|>SIZE: u32 = 1024; pub const MAP_BLOCK_SIZE: u32 = 20; pub const STEP_LEN: u32 = 10; pub const CUBE_NUM...
code_fim
medium
{ "lang": "rust", "repo": "SKTT1Ryze/rust-rpg", "path": "/config/src/size.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tempbottle/rust-paillier-1 path: /examples/specific.rs extern crate paillier; #[cfg(not(feature="keygen"))] fn main() { println!("*** please run with 'keygen' feature ***") } <|fim_suffix|> let c1 = MyScheme::encrypt(&eek, &10); let c2 = MyScheme::encrypt(&eek, &20); let c3 = M...
code_fim
hard
{ "lang": "rust", "repo": "tempbottle/rust-paillier-1", "path": "/examples/specific.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use paillier::{AbstractPaillier, BigInteger, integral}; // could be a specific type such as RampBigInteger as well use paillier::coding::*; use paillier::traits::*; type MyScheme = AbstractPaillier<BigInteger>; let (ek, dk) = MyScheme::keypair().keys(); let code = integral::Code:...
code_fim
medium
{ "lang": "rust", "repo": "tempbottle/rust-paillier-1", "path": "/examples/specific.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use paillier::{AbstractPaillier, BigInteger, integral}; // could be a specific type such as RampBigInteger as well use paillier::coding::*; use paillier::traits::*; type MyScheme = AbstractPaillier<BigInteger>; let (ek, dk) = MyScheme::keypair().keys(); let code = integral::Code...
code_fim
medium
{ "lang": "rust", "repo": "tempbottle/rust-paillier-1", "path": "/examples/specific.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)] pub struct AntivirusServer { /// A description for the server. #[serde(rename = "description")] pub description: Option<String>, /// Whether the server is enabled. #[serde(rename = "enabled")] pub enabled: Option<bool>, /// The icap url ...
code_fim
medium
{ "lang": "rust", "repo": "cholcombe973/isilon", "path": "/src/models/antivirus_server.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/antivirus_server.rs /// AntivirusServer : An ICAP server that contains virus definitions. <|fim_suffix|>#[derive(Debug, Serialize, Deserialize)] pub struct AntivirusServer { /// A description for the server. #[serde(rename = "description")] pub ...
code_fim
medium
{ "lang": "rust", "repo": "cholcombe973/isilon", "path": "/src/models/antivirus_server.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maxer456/ALVR path: /alvr/xtask/src/command.rs use crate::BResult; use std::{ env, path::Path, process::{Command, Stdio}, }; pub fn run_as_shell_in(workdir: &Path, shell: &str, shell_flag: &str, cmd: &str) -> BResult { println!("\n> {}", cmd); let output = Command::new(shel...
code_fim
hard
{ "lang": "rust", "repo": "maxer456/ALVR", "path": "/alvr/xtask/src/command.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if output.status.success() { Ok(()) } else { Err(format!( "Command failed: {}", String::from_utf8_lossy(&output.stderr) ) .into()) } }<|fim_prefix|>// repo: maxer456/ALVR path: /alvr/xtask/src/command.rs use crate::BResult; use std::{ ...
code_fim
hard
{ "lang": "rust", "repo": "maxer456/ALVR", "path": "/alvr/xtask/src/command.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: juzi5201314/coolq-sdk-rust path: /src/events/private_message.rs use std::os::raw::c_char; use crate::targets::{ message::{Message, SendMessage}, user::User, }; #[derive(Debug, Clone)] pub enum PrivateMessageType { Friend, Group, Discuss, Other, } <|fim_suffix|> pub ...
code_fim
hard
{ "lang": "rust", "repo": "juzi5201314/coolq-sdk-rust", "path": "/src/events/private_message.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn reply(&self, msg: impl ToString) -> crate::api::Result<i32> { self.user.send_message(msg) } pub fn get_sub_type(&self) -> PrivateMessageType { PrivateMessageType::from(self.sub_type) } }<|fim_prefix|>// repo: juzi5201314/coolq-sdk-rust path: /src/events/private_mes...
code_fim
hard
{ "lang": "rust", "repo": "juzi5201314/coolq-sdk-rust", "path": "/src/events/private_message.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DougAnderson444/deno-autosuggest path: /rust/core/src/utils/limitsort.rs use std::cmp::Ordering; pub trait LimitSort: Iterator + Sized { fn limit_sort<F>(self, limit: usize, sort_fn: F) -> LimitSortIter<Self::Item, Self, F> where F: (FnMut(&Self::Item, &Self::Item) -> Ordering) ...
code_fim
hard
{ "lang": "rust", "repo": "DougAnderson444/deno-autosuggest", "path": "/rust/core/src/utils/limitsort.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> { let Self { buffer, source, sort_fn, done, .. } = self; let limit = self.limit; let stable = self.stable; let mut sort = |buffer: &mut Vec<T>| { if stable { buffer.sort_by(|x, y| sort_fn(x, y)); ...
code_fim
hard
{ "lang": "rust", "repo": "DougAnderson444/deno-autosuggest", "path": "/rust/core/src/utils/limitsort.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn name(&self) -> &'static str { match self { &PublicKey::Ed25519(_) => "ssh-ed25519", } } } #[derive(Debug,Clone)] pub struct Algorithm { pub public_host_key: PublicKey, pub secret_host_key: SecretKey, } use std::path::Path; impl Algorithm { pub fn l...
code_fim
hard
{ "lang": "rust", "repo": "posix4e/thrussh-snapshot", "path": "/src/key.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: posix4e/thrussh-snapshot path: /src/key.rs // Copyright 2016 Pierre-Étienne Meunier // // 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/lic...
code_fim
hard
{ "lang": "rust", "repo": "posix4e/thrussh-snapshot", "path": "/src/key.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kubo/rosy path: /src/num/integer/mod.rs rom<Integer> for AnyObject { #[inline] fn from(obj: Integer) -> Self { obj.0.into() } } impl<O: Object> PartialEq<O> for Integer { #[inline] fn eq(&self, other: &O) -> bool { let other = other.as_any_object(); let other_id ...
code_fim
hard
{ "lang": "rust", "repo": "kubo/rosy", "path": "/src/num/integer/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl PartialEq<Integer> for $t { #[inline] fn eq(&self, other: &Integer) -> bool { other == self } } impl PartialOrd<$t> for Integer { #[inline] fn partial_cmp(&self, other: &$t) -> Option<Ordering> { ...
code_fim
hard
{ "lang": "rust", "repo": "kubo/rosy", "path": "/src/num/integer/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kubo/rosy path: /src/num/integer/mod.rs t: u64) -> Self { if mem::size_of::<u64>() == mem::size_of::<usize>() { (int as usize).into() } else { Self::unpack(slice::from_ref(&int)) } } } impl From<i64> for Integer { #[inline] fn from(int...
code_fim
hard
{ "lang": "rust", "repo": "kubo/rosy", "path": "/src/num/integer/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Amatrelan/runner path: /src/config.rs use indexmap::IndexMap; use log::debug; use serde_derive::Deserialize; use serde_derive::Serialize; use std::collections::HashMap; use toml; fn bool_default() -> bool { false } #[derive(Serialize, Deserialize, Debug)] pub struct Global { log_level...
code_fim
hard
{ "lang": "rust", "repo": "Amatrelan/runner", "path": "/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> task: IndexMap<String, Task>, } impl Default for Config { fn default() -> Self { let mut imap: IndexMap<String, Task> = IndexMap::new(); imap.insert("example_task".to_string(), Task::default()); Self { global: Global::default(), task: imap, ...
code_fim
hard
{ "lang": "rust", "repo": "Amatrelan/runner", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avangogo/local-flags path: /src/degree.rs use flag_algebra::flags::{CGraph, Colored, Graph}; use flag_algebra::*; use ndarray::ScalarOperand; use num::{FromPrimitive, Num, One, Zero}; use std::collections::BTreeSet; use std::fmt::Display; use std::ops::{AddAssign, Neg}; use std::marker::{Sync, S...
code_fim
hard
{ "lang": "rust", "repo": "avangogo/local-flags", "path": "/src/degree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.is_connected_to(|i| i == 0) } } // Workaround to have function pointers computing the extensions macro_rules! ext { ($i:expr) => { |flag, type_size| flag.is_edge($i, type_size) }; } fn ext<F: Degree>() -> [fn(&F, usize) -> bool; 13] { [ ext!(0), ext!(...
code_fim
hard
{ "lang": "rust", "repo": "avangogo/local-flags", "path": "/src/degree.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang-ru/rust_book_2ed path: /second-edition/examples/ch18/ch18_9/src/main.rs fn main() { let x = 5; match x { 1...5 => println!("one through five"), _ => println!("something else"), } for <|fim_suffix|>ough five"), _ => println!("something e...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang-ru/rust_book_2ed", "path": "/second-edition/examples/ch18/ch18_9/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>x in 1..7 { match x { 1...5 => println!("`for` one through five"), _ => println!("something else"), } } }<|fim_prefix|>// repo: rust-lang-ru/rust_book_2ed path: /second-edition/examples/ch18/ch18_9/src/main.rs fn main() { let x = 5; match x { 1...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang-ru/rust_book_2ed", "path": "/second-edition/examples/ch18/ch18_9/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ough five"), _ => println!("something else"), } } }<|fim_prefix|>// repo: rust-lang-ru/rust_book_2ed path: /second-edition/examples/ch18/ch18_9/src/main.rs fn main() { let x = 5; match x { 1...5 => println!("one t<|fim_middle|>hrough five"), _ => println!(...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang-ru/rust_book_2ed", "path": "/second-edition/examples/ch18/ch18_9/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// https://transform.tools/json-to-rust-serde println!("Hello World!"); }<|fim_prefix|>// repo: anandijain/learning path: /rust/hello.rs fn main() { /* Block comments whic<|fim_middle|>h go to the closing delimiter. */
code_fim
easy
{ "lang": "rust", "repo": "anandijain/learning", "path": "/rust/hello.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anandijain/learning path: /rust/hello.rs fn main() { /* Block comments whic<|fim_suffix|>// https://transform.tools/json-to-rust-serde println!("Hello World!"); }<|fim_middle|>h go to the closing delimiter. */
code_fim
easy
{ "lang": "rust", "repo": "anandijain/learning", "path": "/rust/hello.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn feedback_max_val() { assert_eq!( feedback("3,26,1001,26,-4,26,3,27,1002,27,2,27,1,27,26,27,4,27,1001,28,-1,28,1005,28,6,99,0,0,5"), 139629729 ); assert_eq!( feedback("3,52,1001,52,-5,52,3,53,1,52,56,54,1007,54,5,55,1005,55,26,...
code_fim
hard
{ "lang": "rust", "repo": "bk2204/adventofcode-work", "path": "/2019/src/lib/d7/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bk2204/adventofcode-work path: /2019/src/lib/d7/mod.rs use crate::d2; use permutator::Permutation; pub struct Chain<'a> { prog: &'a str, initial: i64, } impl<'a> Chain<'a> { pub fn new(prog: &'a str, initial: i64) -> Self { Chain { prog, initial } } pub fn run(&sel...
code_fim
hard
{ "lang": "rust", "repo": "bk2204/adventofcode-work", "path": "/2019/src/lib/d7/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( find_max("3,15,3,16,1002,16,10,16,1,16,15,15,4,15,99,0,0"), 43210 ); assert_eq!( find_max("3,23,3,24,1002,24,10,24,1002,23,-1,23,101,5,23,23,1,24,23,23,4,23,99,0,0"), 54321 ); assert_eq!(find_max("3,31,3,32...
code_fim
hard
{ "lang": "rust", "repo": "bk2204/adventofcode-work", "path": "/2019/src/lib/d7/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return Err(syn::Error::new(item_trait.span(), msg)) } let has_runtime_upgrade = item.items.iter().any(|i| match i { syn::ImplItem::Fn(method) => method.sig.ident == "on_runtime_upgrade", _ => false, }); Ok(Self { attr_span, index, instances, has_runtime_upgrade, where_cla...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/support/procedural/src/pallet/parse/hooks.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl HooksDef { pub fn try_from( attr_span: proc_macro2::Span, index: usize, item: &mut syn::Item, ) -> syn::Result<Self> { let item = if let syn::Item::Impl(item) = item { item } else { let msg = "Invalid pallet::hooks, expected item impl"; return Err(syn::Error::new(item.span(), msg...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/support/procedural/src/pallet/parse/hooks.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paritytech/substrate path: /frame/support/procedural/src/pallet/parse/hooks.rs // This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this fil...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/support/procedural/src/pallet/parse/hooks.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: giovanni-shibaki/path_planning path: /visualization/src/lib.rs #[macro_use] mod utils; use nalgebra as na; use plotters::prelude::*; use plotters_canvas::CanvasBackend; use std::borrow::Borrow; use std::collections::HashSet; use wasm_bindgen::prelude::*; use web_sys::HtmlCanvasElement; use kd_...
code_fim
hard
{ "lang": "rust", "repo": "giovanni-shibaki/path_planning", "path": "/visualization/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let color = RGBColor(0, 0, 0).mix(0.5); if series.len() > 0 { root.draw(&PathElement::new( series.clone(), ShapeStyle::from(&color).filled(), ))?; } } let waypoints = if let Some(r...
code_fim
hard
{ "lang": "rust", "repo": "giovanni-shibaki/path_planning", "path": "/visualization/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lamaboy2018/RNgl path: /src/dataprocess/Process.rs extern crate crossbeam; use std::thread; use std::sync::{Arc, Mutex, Condvar, RwLock}; use std::string::String; use std::vec::*; use std::net::{TcpListener, TcpStream}; use std::io::BufReader; use std::sync::mpsc::{channel, Sender, Receiver,...
code_fim
hard
{ "lang": "rust", "repo": "lamaboy2018/RNgl", "path": "/src/dataprocess/Process.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { if !qdata.index.run() { // println!("start to wait >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); qdata = cvar.wait(qdata).unwrap(); } let _r = qdata.index.dequeue(); let ref mut data = qdata.data[_r]; //dat...
code_fim
hard
{ "lang": "rust", "repo": "lamaboy2018/RNgl", "path": "/src/dataprocess/Process.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use client_manager::handle_client; #[tokio::main] async fn main() -> Result<(), error::Error> { env_logger::init(); let matches = Command::new("earthengineweb") .version("0.2.0") .about("Earth Engine's web site") .author("Earth Engine") .arg( Arg::new(...
code_fim
hard
{ "lang": "rust", "repo": "earthengine/rocks", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut incoming = get_incoming(conf.incoming).await?; loop { if let Ok(c) = incoming.next_client().await { let o_conf = conf.outgoing.clone(); tokio::spawn(handle_client(c, o_conf)); } else { break; } } Ok(()) }<|fim_prefix|>// ...
code_fim
hard
{ "lang": "rust", "repo": "earthengine/rocks", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: earthengine/rocks path: /src/main.rs #![deny(bare_trait_objects)] use clap::{Arg, Command}; use futures::Future; use log::{error, info}; use std::io::Read; use std::{fs::File, pin::Pin}; pub type PinboxedSendFuture<'a, O> = Pin<Box<dyn Future<Output = O> + Send + 'a>>; pub type StandardFuture<...
code_fim
medium
{ "lang": "rust", "repo": "earthengine/rocks", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: svartalf/unbound-telemetry path: /src/statistics/parser/tests.rs use claim::{assert_ok, assert_some_eq}; use super::Parser; use crate::statistics::{Class, Rcode, Rtype}; static STATS: &str = include_str!("../../../assets/test_text_stats.txt"); static STATS_1_13_2: &str = include_str!("../../.....
code_fim
hard
{ "lang": "rust", "repo": "svartalf/unbound-telemetry", "path": "/src/statistics/parser/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(stats.num_query_tcp, 0); assert_eq!(stats.num_query_tcp_out, 2); assert_eq!(stats.num_query_tls, 0); assert_eq!(stats.num_query_tls_resume, 0); assert_eq!(stats.num_query_ipv6, 0); assert_eq!(stats.num_query_https, 10); assert_eq!(stats.flags.qr, 0); assert_eq!(...
code_fim
hard
{ "lang": "rust", "repo": "svartalf/unbound-telemetry", "path": "/src/statistics/parser/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dayang/leetcode-rs path: /min-cost-climbing-stairs/src/main.rs //! ## 使用最小花费爬楼梯 ## //! [原题目地址](https://leetcode-cn.com/problems/min-cost-climbing-stairs/) 难度:<b>简单</b> //! ### 题目描述 ### //! 数组的每个索引做为一个阶梯,第 i个阶梯对应着一个非负数的体力花费值 cost[i](索引从0开始)。 //! //! 每当你爬上一个阶梯你都要花费对应的体力花费值,然后你可以选择继续爬一个阶梯或者爬两个阶梯。...
code_fim
medium
{ "lang": "rust", "repo": "dayang/leetcode-rs", "path": "/min-cost-climbing-stairs/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Solution { pub fn min_cost_climbing_stairs(cost: Vec<i32>) -> i32 { let mut f1 = cost[0]; let mut f2 = cost[1]; for i in 2..cost.len() { let t = std::cmp::min(f1, f2) + cost[i]; f1 = f2; f2 = t; } std::cmp::min(f1, f2) ...
code_fim
medium
{ "lang": "rust", "repo": "dayang/leetcode-rs", "path": "/min-cost-climbing-stairs/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Orange-OpenSource/hurl path: /packages/hurl/src/http/version.rs /* * Hurl (https://hurl.dev) * Copyright (C) 2023 Orange * * 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 Lic...
code_fim
hard
{ "lang": "rust", "repo": "Orange-OpenSource/hurl", "path": "/packages/hurl/src/http/version.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns the libraries and features of libcurl. /// /// Output should be similar to `curl --version` /// - <https://github.com/curl/curl/blob/master/lib/version.c> /// - <https://github.com/curl/curl/blob/master/src/tool_help.c> pub fn libcurl_version_info() -> CurlVersionInfo { let version = curl:...
code_fim
hard
{ "lang": "rust", "repo": "Orange-OpenSource/hurl", "path": "/packages/hurl/src/http/version.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> AsyncLineBufferBuilder::new().build() } async fn try_get_existing(&self) -> Option<AsyncLineBuffer> { let maybe_buf = self.pool.lock().await.pop(); maybe_buf.and_then(|mut b| { b.refresh(); Some(b) }) } }<|fim_prefix|>// repo: andysale...
code_fim
medium
{ "lang": "rust", "repo": "andysalerno/toygrep", "path": "/src/buffer/buffer_pool.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn new() -> BufferPool { let pool = Mutex::new((0..4).map(|_| Self::generate_new()).collect()); Self { pool } } pub(crate) async fn return_to_pool(&self, buf: AsyncLineBuffer) { self.pool.lock().await.push(buf); } pub(crate) async fn pool_size(&sel...
code_fim
hard
{ "lang": "rust", "repo": "andysalerno/toygrep", "path": "/src/buffer/buffer_pool.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andysalerno/toygrep path: /src/buffer/buffer_pool.rs use super::async_line_buffer::{AsyncLineBuffer, AsyncLineBufferBuilder}; use async_std::sync::Mutex; #[derive(Default, Debug)] pub(crate) struct BufferPool { pool: Mutex<Vec<AsyncLineBuffer>>, } impl BufferPool { /// Get a buffer, ei...
code_fim
medium
{ "lang": "rust", "repo": "andysalerno/toygrep", "path": "/src/buffer/buffer_pool.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Krankdud/now-playing path: /src/text.rs use sdl2::pixels::Color; use sdl2::render::TextureCreator; use sdl2::render::WindowCanvas; use sdl2::ttf::Font; use sdl2::ttf::Sdl2TtfContext; use std::path::Path; use crate::song::Song; pub struct TextRenderer<'a, T> { font: Font<'a, 'a>, textur...
code_fim
hard
{ "lang": "rust", "repo": "Krankdud/now-playing", "path": "/src/text.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn render(&self, canvas: &mut WindowCanvas, string: &str, x: i32, y: i32, color: Color) { let (width, _height) = self.font.size_of(string).unwrap(); if x + (width as i32) > self.text_width { let splits: Vec<&str> = string.split(' ').collect(); let mut trunca...
code_fim
hard
{ "lang": "rust", "repo": "Krankdud/now-playing", "path": "/src/text.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! make_postgres_type( ($(#[$doc:meta] $oid:ident => $variant:ident $(member $member:ident)*),+) => ( /// A Postgres type #[deriving(PartialEq, Eq, Clone, Show)] pub enum Type { $( #[$doc] $variant, )+ ...
code_fim
hard
{ "lang": "rust", "repo": "kyledewey/rust-postgres", "path": "/src/types/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kyledewey/rust-postgres path: /src/types/mod.rs 0 => { let type_ = match tag & inclusive_flag { 0 => BoundType::Exclusive, _ => BoundType::Inclusive, }; ...
code_fim
hard
{ "lang": "rust", "repo": "kyledewey/rust-postgres", "path": "/src/types/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kyledewey/rust-postgres path: /src/types/mod.rs t(); let mut elements = Vec::with_capacity(nele); for _ in range(0, nele) { let len = try!(rdr.read_be_i32()); if len < 0 { elements.push(None); } else { ...
code_fim
hard
{ "lang": "rust", "repo": "kyledewey/rust-postgres", "path": "/src/types/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let secret_number = generate_secret_number(); let guess = ask_for_input(); println!("You guessed: {}", guess); match guess.cmp(&secret_number) { Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), Ordering::Equal => println!("You W...
code_fim
medium
{ "lang": "rust", "repo": "hindenbug/learning-rust", "path": "/doc-rust-lang/guessing_game/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hindenbug/learning-rust path: /doc-rust-lang/guessing_game/src/main.rs extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; // Rust's built in number types i8, i16, i32, i64, u8, u16, u32, u64, isize, usize, f32, f64 // learnings: let, match, methods, associated functions, us...
code_fim
hard
{ "lang": "rust", "repo": "hindenbug/learning-rust", "path": "/doc-rust-lang/guessing_game/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rurudo/rust-trace-event-profiler path: /src/lib.rs #[macro_use] extern crate derive_builder; <|fim_suffix|>pub use event_builder::EventBuilder; pub use profiler::Profiler; pub use serialize_root::TraceEventFormat; pub use trace_event::Argument; pub use trace_event::TraceEvent;<|fim_middle|>mod ...
code_fim
medium
{ "lang": "rust", "repo": "rurudo/rust-trace-event-profiler", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use event_builder::EventBuilder; pub use profiler::Profiler; pub use serialize_root::TraceEventFormat; pub use trace_event::Argument; pub use trace_event::TraceEvent;<|fim_prefix|>// repo: rurudo/rust-trace-event-profiler path: /src/lib.rs #[macro_use] extern crate derive_builder; <|fim_middle|>mod ...
code_fim
medium
{ "lang": "rust", "repo": "rurudo/rust-trace-event-profiler", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_boot_next() -> Result<u16> { let mut data = [0; 2]; let count = get("BootNext", &mut data)?; if count == 2 { Ok((data[0] as u16) | ((data[1] as u16) << 8)) } else { Err(Error::LoadError) } } pub fn set_boot_next(num_opt: Option<u16>) -> Result<usize> { i...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/uefi", "path": "/crates/uefi_std/src/vars.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redox-os/uefi path: /crates/uefi_std/src/vars.rs use core::ptr; use uefi::guid::GLOBAL_VARIABLE_GUID; use uefi::status::{Error, Result}; use crate::ffi::wstr; use crate::slice; use crate::system_table; fn get(name: &str, data: &mut [u8]) -> Result<usize> { let wname = wstr(name); let m...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/uefi", "path": "/crates/uefi_std/src/vars.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn set_boot_item(num: u16, data: &[u8]) -> Result<usize> { set(&format!("Boot{:>04X}", num), data) } pub fn get_os_indications() -> Result<u64> { let mut data = [0; 8]; let count = get("OsIndications", &mut data)?; if count == 8 { Ok( (data[0] as u64) | ...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/uefi", "path": "/crates/uefi_std/src/vars.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CSML-by-Clevy/csml-engine path: /csml_cli/src/interface/init_menu.rs use crate::interface::{MenuComponent, AppState, MenuItem, MenuType}; use std::iter::Iterator; const AWS_REGIONS_PAYLOAD: &[&str] = &[ "US East (Ohio) us-east-2", "US East (N. Virginia) us-east-1", "US West (N. Cali...
code_fim
hard
{ "lang": "rust", "repo": "CSML-by-Clevy/csml-engine", "path": "/csml_cli/src/interface/init_menu.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Debug, Clone)] pub struct InitMenu { pub start: Vec<MenuItem>, } impl MenuType for InitMenu { fn init() -> Box<dyn MenuType> { let mongodb_sub_menu = vec![ MenuItem::new( "MongoDB Connection String URI", MenuComponent::Text{text: "mong...
code_fim
hard
{ "lang": "rust", "repo": "CSML-by-Clevy/csml-engine", "path": "/csml_cli/src/interface/init_menu.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>1, 2, 3); call_2("argument here"); call_3(); "#, ); }<|fim_prefix|>// repo: CalliEve/boa path: /boa_engine/src/syntax/ast/node/call/tests.rs #[test] fn fmt() { super::super::tes<|fim_middle|>t_formatting( r#" call_1(
code_fim
easy
{ "lang": "rust", "repo": "CalliEve/boa", "path": "/boa_engine/src/syntax/ast/node/call/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CalliEve/boa path: /boa_engine/src/syntax/ast/node/call/tests.rs #[test] fn fmt() { super::super::test_formatting( r#" call_1(<|fim_suffix|>); call_3(); "#, ); }<|fim_middle|>1, 2, 3); call_2("argument here"
code_fim
easy
{ "lang": "rust", "repo": "CalliEve/boa", "path": "/boa_engine/src/syntax/ast/node/call/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while let Some(rec) = world.hit(&ray, 0.00001, std::f32::MAX) { // Maximum number of bounces. If exceeded, return the // result of all interactions so far with the scene. if bounces >= max_bounce { break; } // Get the scattering result from interact...
code_fim
hard
{ "lang": "rust", "repo": "Avarel/raytracer-in-one-weekend-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Get the scattering result from interacting with // the material of the object. let Scatter { scattered, attenuation, } = rec.material.scatter(ray, &rec); // If the ray is completely absorbed, then the only // light that could poss...
code_fim
hard
{ "lang": "rust", "repo": "Avarel/raytracer-in-one-weekend-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Avarel/raytracer-in-one-weekend-rs path: /src/main.rs mod camera; mod material; mod model; mod ray; mod vec3; use camera::Camera; use material::{Material, Scatter}; use model::Model; use ray::Ray; use vec3::{vec3, Vec3}; use image::{ImageBuffer, Rgb, RgbImage}; use indicatif::{ProgressBar, Pr...
code_fim
hard
{ "lang": "rust", "repo": "Avarel/raytracer-in-one-weekend-rs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }