text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> assert_approx_eq!( complex_unit!().unsaved(&simple_unit!()), 9.0 * ( 3.0 * (4.0/6.0) * (4.0/6.0) * (5.0/6.0)+ 6.0 * 0.5 * (4.0/6.0) + 3.5 * (4.0/6.0) * (5.0/6.0))); } #[test] fn test_expected_damage() { assert_approx_eq!( simple_unit!()....
code_fim
hard
{ "lang": "rust", "repo": "ruchnar/rusthammer", "path": "/src/units/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>unsafe auto trait AutoUnsafe {} impl !Auto for bool {} impl !AutoUnsafe for bool {} struct AutoBool(bool); impl Auto for AutoBool {} unsafe impl AutoUnsafe for AutoBool {} fn take_auto<T: Auto>(_: T) {} fn take_auto_unsafe<T: AutoUnsafe>(_: T) {} fn main() { take_auto(0); take_auto(AutoBool(t...
code_fim
medium
{ "lang": "rust", "repo": "PkmX/rust", "path": "/src/test/run-pass/auto-traits.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { take_auto(0); take_auto(AutoBool(true)); take_auto_unsafe(0); take_auto_unsafe(AutoBool(true)); }<|fim_prefix|>// repo: PkmX/rust path: /src/test/run-pass/auto-traits.rs // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this...
code_fim
medium
{ "lang": "rust", "repo": "PkmX/rust", "path": "/src/test/run-pass/auto-traits.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PkmX/rust path: /src/test/run-pass/auto-traits.rs // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://w...
code_fim
hard
{ "lang": "rust", "repo": "PkmX/rust", "path": "/src/test/run-pass/auto-traits.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs // Test to ensure we only report an error for the first issued loan that // conflicts with a new loan, as opposed to every issued loan. This keeps us // down to O(n) errors (for n problem lines), in...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut x = 1; let mut addr = vec![]; loop { match 1 { 1 => { addr.push(&mut x); } //~ ERROR [E0499] 2 => { addr.push(&mut x); } //~ ERROR [E0499] _ => { addr.push(&mut x); } //~ ERROR [E0499] } } }<|fim_prefix|>// repo: IThawk/rust-proje...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlterionX/crossarena path: /src/ui/hud.rs use gdnative::{ init::{Property, PropertyHint, PropertyUsage}, Label, NodePath, Range, VBoxContainer, }; #[derive(Debug)] struct Cfg { arena_path: NodePath, hp_bar_path: NodePath, wave_display_path: NodePath, } impl Cfg ...
code_fim
hard
{ "lang": "rust", "repo": "AlterionX/crossarena", "path": "/src/ui/hud.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.data.max_hp = f64::from_bits(max_hp); log::info!("Received max hp data ({}).", self.data.max_hp); if let Some(mut hp_bar) = unsafe { owner.get_node(self.cfg.hp_bar_path.new_ref()).and_then(|n| n.cast::<Range>()) } { unsafe { hp_bar.set_max(self....
code_fim
hard
{ "lang": "rust", "repo": "AlterionX/crossarena", "path": "/src/ui/hud.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: polachok/libmarisa path: /tests/test.rs extern crate libmarisa as marisa; <|fim_suffix|> for key in keys { keyset.push(key, 0); } let len = keyset.num_keys(); assert!(len == keys_len); }<|fim_middle|>#[test] fn test_keyset() { let mut keyset = marisa::KeySet::new(); ...
code_fim
medium
{ "lang": "rust", "repo": "polachok/libmarisa", "path": "/tests/test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut keyset = marisa::KeySet::new(); let keys = vec!("hello", "world"); let keys_len = keys.len(); for key in keys { keyset.push(key, 0); } let len = keyset.num_keys(); assert!(len == keys_len); }<|fim_prefix|>// repo: polachok/libmarisa path: /tests/test.rs extern...
code_fim
easy
{ "lang": "rust", "repo": "polachok/libmarisa", "path": "/tests/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shmilyvidian/algorithm014-algorithm014 path: /Week_04/lemonade-change.rs // 860. 柠檬水找零 impl Solution { pub fn lemonade_change(bills: Vec<i32>) -> bool { let mut five:i32 = 0; let mut ten:i32 = 0; let mut isDone: bool = true; for value in bills{ if ...
code_fim
hard
{ "lang": "rust", "repo": "shmilyvidian/algorithm014-algorithm014", "path": "/Week_04/lemonade-change.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> }else if(five >= 3){ five -= 3; }else{ isDone = false; } } } isDone } }<|fim_prefix|>// repo: shmilyvidian/algorithm014-algorithm014 path: /Week_04/lemonade-change.rs // 860. 柠檬水找零 impl ...
code_fim
hard
{ "lang": "rust", "repo": "shmilyvidian/algorithm014-algorithm014", "path": "/Week_04/lemonade-change.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnzlbg/ispc-rs path: /examples/multi_file/build.rs extern crate ispc; fn main() { // We need to use a custom config to explicitly not generate debug info // for ISPC code on windows otherwise we get repeated symbol declarations let mut cfg = ispc::Config::new(); if cfg!(windows)...
code_fim
medium
{ "lang": "rust", "repo": "gnzlbg/ispc-rs", "path": "/examples/multi_file/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> cfg.debug(false); } // Only re-run the build script if the ISPC files have been changed let ispc_files = vec!["src/file_a.ispc", "src/file_b.ispc"]; for s in &ispc_files[..] { cfg.file(*s); } cfg.compile("multi_file") }<|fim_prefix|>// repo: gnzlbg/ispc-rs path: /exampl...
code_fim
medium
{ "lang": "rust", "repo": "gnzlbg/ispc-rs", "path": "/examples/multi_file/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} #[inline] pub fn cudnn_create_reduce_tensor_descriptor(reduce_tensor_desc: *mut*mut _ReduceTensorDescriptorStruct) { #[cfg(not(feature = "disable_checks"))] { unsafe { cudnnCreateReduceTensorDescriptor(reduce_tensor_desc) }.assert_success(); } #[cfg(feature = "disable_checks")] ...
code_fim
hard
{ "lang": "rust", "repo": "Ltei/cumath_nn", "path": "/src/ffi/reduce_tensor_descriptor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ltei/cumath_nn path: /src/ffi/reduce_tensor_descriptor.rs use super::{CudnnStatus, CudnnDataType, CudnnNanPropagation, CudnnReduceTensorOp, CudnnReduceTensorIndices, CudnnIndicesType}; pub enum _ReduceTensorDescriptorStruct {} #[allow(non_snake_case)] extern { fn cudnnCreateReduceTe...
code_fim
hard
{ "lang": "rust", "repo": "Ltei/cumath_nn", "path": "/src/ffi/reduce_tensor_descriptor.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let id = self.counter; self.counter += 1; id } pub fn insert_vertex(&mut self, vertex: T) -> usize { let id = self.alloc_id(); self.vertexes.insert(id, vertex); if !self.in_edges.contains_key(&id) { self.in_edges.insert(id, BTreeSet::new()); } if !self.out_edges....
code_fim
hard
{ "lang": "rust", "repo": "peterhj/rembrandt", "path": "/src/graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peterhj/rembrandt path: /src/graph.rs use std::collections::{BTreeMap, BTreeSet}; pub struct Graph<T> { pub vertexes: BTreeMap<usize, T>, pub in_edges: BTreeMap<usize, BTreeSet<usize>>, pub out_edges: BTreeMap<usize, BTreeSet<usize>>, counter: usize, } <|fim_suffix|> let...
code_fim
hard
{ "lang": "rust", "repo": "peterhj/rembrandt", "path": "/src/graph.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn insert_vertex(&mut self, vertex: T) -> usize { let id = self.alloc_id(); self.vertexes.insert(id, vertex); if !self.in_edges.contains_key(&id) { self.in_edges.insert(id, BTreeSet::new()); } if !self.out_edges.contains_key(&id) { self.out_edges.insert(id, BTreeSet::...
code_fim
hard
{ "lang": "rust", "repo": "peterhj/rembrandt", "path": "/src/graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Get the address hash pub fn get_address_hash(&self) -> &ShortAddressHash { &self.address_hash } /// Set the address hash pub fn set_address_hash(&mut self, val: ShortAddressHash) { self.address_hash = val; } /// Get the number of recipients pub fn get_nu...
code_fim
hard
{ "lang": "rust", "repo": "rust-chainblock/blockchain7", "path": "/transaction/std/src/memo/destination.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-chainblock/blockchain7 path: /transaction/std/src/memo/destination.rs // Copyright (c) 2018-2021 The MobileCoin Foundation //! Object for 0x0200 Destination memo type //! //! This was proposed for standardization in mobilecoinfoundation/mcips/pull/4 use super::RegisteredMemoType; use crat...
code_fim
hard
{ "lang": "rust", "repo": "rust-chainblock/blockchain7", "path": "/transaction/std/src/memo/destination.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl EntryFlags { pub fn from_elf_section_flags(section: &ElfSection) -> EntryFlags { use multiboot2::{ELF_SECTION_ALLOCATED, ELF_SECTION_WRITABLE, ELF_SECTION_EXECUTABLE}; let mut flags = EntryFlags::empty(); if section.flags().contains(ELF_SECTION_ALLOCATED) { /...
code_fim
hard
{ "lang": "rust", "repo": "Infinity-OS/infinity", "path": "/arch/x86_64/src/memory/paging/entry.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Infinity-OS/infinity path: /arch/x86_64/src/memory/paging/entry.rs use memory::Frame; use multiboot2::ElfSection; pub struct Entry(u64); impl Entry { pub fn is_unused(&self) -> bool { self.0 == 0 } pub fn set_unused(&mut self) { self.0 = 0; } <|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "Infinity-OS/infinity", "path": "/arch/x86_64/src/memory/paging/entry.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if section.flags().contains(ELF_SECTION_ALLOCATED) { // section is loaded to memory flags = flags | PRESENT; } if section.flags().contains(ELF_SECTION_WRITABLE) { flags = flags | WRITABLE; } if !section.flags().contains(ELF_SECTIO...
code_fim
hard
{ "lang": "rust", "repo": "Infinity-OS/infinity", "path": "/arch/x86_64/src/memory/paging/entry.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for y in 0..hi_y { let full_y = y as isize + obj.y as isize - 16; if full_y > fb::SCREEN_SIZE.1 as isize || full_y < 0 || full_y != self.scanline_sweeper.ly() as isize { continue; ...
code_fim
hard
{ "lang": "rust", "repo": "JennToo/j2gbc", "path": "/j2gbc/src/lcd.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JennToo/j2gbc path: /j2gbc/src/lcd.rs imer: Timer::new( SCREEN_CYCLE_TIME, fb::SCREEN_SIZE.1 as u64 * LINE_CYCLE_TIME, VBLANK_DURATION, ), mode10_timer: Timer::new( LINE_CYCLE_TIME, LINE_CYCLE...
code_fim
hard
{ "lang": "rust", "repo": "JennToo/j2gbc", "path": "/j2gbc/src/lcd.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JennToo/j2gbc path: /j2gbc/src/lcd.rs ), running_until_cycle: 0, scanline_sweeper: scanline::ScanlineSweeper::new(), tiles: [tile::MonoTile::default(); TILE_COUNT], objs: [obj::Obj::default(); OBJ_COUNT], system_mode: if cgb_mode { ...
code_fim
hard
{ "lang": "rust", "repo": "JennToo/j2gbc", "path": "/j2gbc/src/lcd.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.to_string().to_sql(out) } } impl<DB> FromSql<Text, DB> for AttendanceStatus where DB: Backend, String: FromSql<Text, DB>, { fn from_sql(bytes: Option<&DB::RawValue>) -> deserialize::Result<Self> { String::from_sql(bytes)? .parse::<AttendanceStatus>() ...
code_fim
hard
{ "lang": "rust", "repo": "tonylpt/WhosInBot-Rust", "path": "/src/models/roll_call_responses/attendance.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tonylpt/WhosInBot-Rust path: /src/models/roll_call_responses/attendance.rs use std::fmt; use std::io::Write; use std::str::FromStr; use diesel::backend::Backend; use diesel::deserialize::{self, FromSql}; use diesel::serialize::{self, Output, ToSql}; use diesel::sql_types::Text; #[derive(Clone,...
code_fim
hard
{ "lang": "rust", "repo": "tonylpt/WhosInBot-Rust", "path": "/src/models/roll_call_responses/attendance.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod prelude { pub use crate::autodiff::reverse_mode::{ destructure::Destructure, differentiable::Differentiable, grad, rvar::{Grad, RVar}, }; pub use crate::axes::{Ax, Ax0, DynAx, StatAx}; pub use crate::hkt::*; pub use crate::stack_buffer::StackBuff...
code_fim
hard
{ "lang": "rust", "repo": "dhalf/melange", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> param: RVar<Param>, input: Tensor<VecConstructor, f64, ax!(3), Contiguous>, ) -> RVar<Tensor<VecConstructor, f64, ax!(3), Contiguous>> { let ParamDestructured { a, b } = Param::destructure(param); b + a * RVar::new(input) //a.vvdot(&RVar::new(input))...
code_fim
hard
{ "lang": "rust", "repo": "dhalf/melange", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dhalf/melange path: /src/lib.rs #[cfg(test)] mod tests { use super::prelude::*; use melange_macros::{ax, rvar}; #[test] fn it_works() { let g = grad(|a: RVar<f64>| a + RVar::new(1.0), 1.0); assert_eq!(1.0, g(2.0)); } #[test] fn c2() { fn f(a: R...
code_fim
hard
{ "lang": "rust", "repo": "dhalf/melange", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: skial/back-to-basics path: /rustlang/structs/basic/src/main.rs fn main() { println!("Hello, world!"); let foo: Foo = Foo { a: String::from("hello"), b: 64 <|fim_suffix|>.a, foo.b); } struct Foo { a: String, b: i32 }<|fim_middle|> }; println!("Foo variables are {0}...
code_fim
easy
{ "lang": "rust", "repo": "skial/back-to-basics", "path": "/rustlang/structs/basic/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> }; println!("Foo variables are {0} and {1}", foo.a, foo.b); } struct Foo { a: String, b: i32 }<|fim_prefix|>// repo: skial/back-to-basics path: /rustlang/structs/basic/src/main.rs fn main() { println!("Hello, world!"); let foo<|fim_middle|>: Foo = Foo { a: String::from("he...
code_fim
easy
{ "lang": "rust", "repo": "skial/back-to-basics", "path": "/rustlang/structs/basic/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn register_ltrd(&mut self, fd_flag: u64) { let fd = (fd_flag & 0xffffffff) as RawFd; let mut ev = libc::epoll_event { events: libc::EPOLLIN as u32, u64: fd_flag, }; unsafe { libc::epoll_ctl(self.epfd, libc::EPOLL_CTL_ADD, fd, &m...
code_fim
hard
{ "lang": "rust", "repo": "condy0919/sleepyhead", "path": "/src/io/monitor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: condy0919/sleepyhead path: /src/io/monitor.rs use crate::aux; use crate::io::adaptor; use libc; use std::os::unix::io::RawFd; pub const EVENT_CHANNEL_FLAG: u64 = 0x1 << 32; pub struct Monitor { capacity: usize, epfd: RawFd, evext_chan: adaptor::Adaptor, // TODO event table ...
code_fim
hard
{ "lang": "rust", "repo": "condy0919/sleepyhead", "path": "/src/io/monitor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Run Bit of CC40 is cleared."] VALUE2, #[doc = "GSTATThe register contains the status of the prescaler and each timer slice (idle mode or running)..PRB and prescaler registers are cleared when the Run Bit of CC41 is cleared."] VALUE3, #[doc = "GSTATThe register contains the status of the p...
code_fim
hard
{ "lang": "rust", "repo": "m9s/xmc1000", "path": "/xmc1000/src/ccu40/gctrl/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m9s/xmc1000 path: /xmc1000/src/ccu40/gctrl/mod.rs *self == MSE1R::VALUE2 } } #[doc = "Possible values of the field `MSE2`"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum MSE2R { #[doc = "Shadow transfer can only be requested by SW"] VALUE1, #[doc = "Shadow transfer c...
code_fim
hard
{ "lang": "rust", "repo": "m9s/xmc1000", "path": "/xmc1000/src/ccu40/gctrl/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn bits(&self) -> u8 { match *self { MSDER::VALUE1 => 0, MSDER::VALUE2 => 1, MSDER::VALUE4 => 3, MSDER::_Reserved(bits) => bits, } } #[allow(missing_docs)] #[doc(hidden)] #[inline] pub fn _from(value...
code_fim
hard
{ "lang": "rust", "repo": "m9s/xmc1000", "path": "/xmc1000/src/ccu40/gctrl/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> inode, new_parent, .. } => file_storage.update_parent(inode.into(), new_parent.into()), ArchivedRkyvRequest::UpdateMetadataChangedTime { inode, .. } => { file_storage.update_metadata_changed_time(inode.into()) } ArchivedRkyvRequest::DecrementInode { ...
code_fim
hard
{ "lang": "rust", "repo": "fleetfs/fleetfs", "path": "/src/storage/message_handlers/write_handler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fleetfs/fleetfs path: /src/storage/message_handlers/write_handler.rs use crate::base::{ArchivedRkyvRequest, ErrorCode, RkyvGenericResponse}; use crate::storage::local::FileStorage; pub fn commit_write( request: &ArchivedRkyvRequest, file_storage: &FileStorage, ) -> Result<RkyvGenericRes...
code_fim
hard
{ "lang": "rust", "repo": "fleetfs/fleetfs", "path": "/src/storage/message_handlers/write_handler.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lancelote/upfork path: /src/main.rs use std::io; use std::process::{Command, Output, exit}; use std::io::Write; // ToDo: move ToDos to GitHub issues // ToDo: read Rust CLI book https://rust-cli.github.io/book/index.html // ToDo: proper CLI (e.g. --help) // ToDo: handle errors // ToDo: handle th...
code_fim
hard
{ "lang": "rust", "repo": "lancelote/upfork", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("... rebasing on upstream/master"); let output = Command::new("git") .args(&["rebase", "upstream/master"]) .output() .expect("failed to run rebase"); assert_failure(output); } fn reset() { println!("... hard resetting on upstream/master"); let output =...
code_fim
hard
{ "lang": "rust", "repo": "lancelote/upfork", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rscarson/Lavendeux path: /src-tauri/src/ui/windows/main.rs use std::{thread}; use embedded_lang::get_string; use tauri::{ AppHandle, Window, Manager, WindowMenuEvent, Menu, Submenu, CustomMenuItem }; use super::Logs; use crate::core::language; /// Tabs on the main window #[...
code_fim
hard
{ "lang": "rust", "repo": "rscarson/Lavendeux", "path": "/src-tauri/src/ui/windows/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Hide the main window pub fn hide(&self) -> tauri::Result<()> { let w = self.0.clone(); thread::spawn(move || { w.hide().ok(); }); Ok(()) } /// Create a new menu for the window pub fn get_menu() -> Menu { let lang = lan...
code_fim
hard
{ "lang": "rust", "repo": "rscarson/Lavendeux", "path": "/src-tauri/src/ui/windows/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// impl<'ctx> Drop for FunctionBuilder<'ctx> { // fn drop(&mut self) { // // Don't attempt to finish if the thread is panicking, since the code is likely invalid at // // that stage and will only incur a double panic // if !self.finished && !std::thread::panicking() { // ...
code_fim
hard
{ "lang": "rust", "repo": "Kixiron/crunch-lang", "path": "/crates/crunch-codegen/src/llvm/module/function_builder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kixiron/crunch-lang path: /crates/crunch-codegen/src/llvm/module/function_builder.rs use crate::llvm::{ module::{Builder, BuildingBlock, Module}, types::{FunctionSig, SealedAnyType, Type}, utils::{LLVMString, EMPTY_CSTR}, values::{BasicBlock, FunctionValue, SealedAnyValue, Value}...
code_fim
hard
{ "lang": "rust", "repo": "Kixiron/crunch-lang", "path": "/crates/crunch-codegen/src/llvm/module/function_builder.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.finished = true; let failed_verification = unsafe { LLVMVerifyFunction( self.as_mut_ptr(), LLVMVerifierFailureAction::LLVMReturnStatusAction, ) } != 0; if failed_verification { // This pointer has to...
code_fim
hard
{ "lang": "rust", "repo": "Kixiron/crunch-lang", "path": "/crates/crunch-codegen/src/llvm/module/function_builder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if format!("{:x}", hash).starts_with(goal) { return i; } } return 0; } pub fn main() { let input = "iwrupvqb"; println!("Part 1: {}", compute(input, "00000")); println!("Part 2: {}", compute(input, "000000")); }<|fim_prefix|>// repo: jsvcycling/advent-of-...
code_fim
medium
{ "lang": "rust", "repo": "jsvcycling/advent-of-code-2015", "path": "/src/bin/day_04.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jsvcycling/advent-of-code-2015 path: /src/bin/day_04.rs use md5::{Digest, Md5}; fn compute(prefix: &'static str, goal: &'static str) -> usize { for i in 1.. { let hash = Md5::digest(format!("{}{}", prefix, i).as_bytes()); if format!("{:x}", hash).starts_with(goal) { ...
code_fim
easy
{ "lang": "rust", "repo": "jsvcycling/advent-of-code-2015", "path": "/src/bin/day_04.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Rexagon/instant path: /src/native.rs pub type Instant = std::time::Instant; <|fim_suffix|> (SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)) .expect("System clock was before 1970.") .as_secs_f64() * 1000.0 }<|fim_middle|>/// The current time, in milliseconds....
code_fim
medium
{ "lang": "rust", "repo": "Rexagon/instant", "path": "/src/native.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> (SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)) .expect("System clock was before 1970.") .as_secs_f64() * 1000.0 }<|fim_prefix|>// repo: Rexagon/instant path: /src/native.rs pub type Instant = std::time::Instant; <|fim_middle|>/// The current time, in milliseconds....
code_fim
medium
{ "lang": "rust", "repo": "Rexagon/instant", "path": "/src/native.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: colbyn/wgpu-lab path: /src/utils/floating_duration.rs // Copyright 2017 Thomas Schaller. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // op...
code_fim
hard
{ "lang": "rust", "repo": "colbyn/wgpu-lab", "path": "/src/utils/floating_duration.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Borrow<Duration>> TimeAsFloat for T { fn as_fractional_secs(&self) -> f64 { let dur: &Duration = self.borrow(); dur.as_secs() as f64 + dur.subsec_nanos() as f64 / 1_000_000_000.0 } fn as_fractional_millis(&self) -> f64 { let dur: &Duration = self.borrow(); ...
code_fim
hard
{ "lang": "rust", "repo": "colbyn/wgpu-lab", "path": "/src/utils/floating_duration.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>rintln!("{:?}", mc.get_blocks_with_data(&pos1, &pos2)); mc.set_blocks(&pos3, &pos4, 2,0); mc.set_block(&pos3, 1,0); println!("{:?}", mc.get_height(&pos4)); }<|fim_prefix|>// repo: DasBlackfur/mcpi-api-rust path: /tests/base.rs use mcpi_api::{create, TileVec3}; #[test] fn main() { let mut...
code_fim
medium
{ "lang": "rust", "repo": "DasBlackfur/mcpi-api-rust", "path": "/tests/base.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DasBlackfur/mcpi-api-rust path: /tests/base.rs use mcpi_api::{create, TileVec3}; #[test] fn main() { let mut mc = create("localhost:4711"); mc.post_to_chat("Hello world!"); let pos1 = TileVec3::from(-31<|fim_suffix|>_entity_ids()); println!("{:?}", mc.get_block(&pos1)); prin...
code_fim
medium
{ "lang": "rust", "repo": "DasBlackfur/mcpi-api-rust", "path": "/tests/base.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/plugins/session/restart/src/args.rs // Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. <|fim_suffix|>#[ffx_command()] #[derive(FromArgs, Deb...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/developer/ffx/plugins/session/restart/src/args.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[ffx_command()] #[derive(FromArgs, Debug, PartialEq)] #[argh( subcommand, name = "restart", description = "Restart the current session component. See https://fuchsia.dev/fuchsia-src/glossary#session-component for details." )] pub struct SessionRestartCommand {}<|fim_prefix|>// repo: gnoliyil/...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/developer/ffx/plugins/session/restart/src/args.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub enum RxFuture<'a, U> where U: HalUart + 'static, { Defer(&'a mut UartPeripheral<U>), Error(Error), } impl<'a, U> Future for RxFuture<'a, U> where U: HalUart + 'static, { type Output = Result<usize, Error>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::O...
code_fim
hard
{ "lang": "rust", "repo": "placrosse/drogue-device", "path": "/src/driver/uart/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Transmit bytes from provided tx_buffer over UART. The memory pointed to by the buffer must be available until the return future is await'ed pub fn write<'a>(&'a mut self, tx_buffer: &[u8]) -> TxFuture<'a, U> { match self.tx_state { State::Ready => { log::tra...
code_fim
hard
{ "lang": "rust", "repo": "placrosse/drogue-device", "path": "/src/driver/uart/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: placrosse/drogue-device path: /src/driver/uart/mod.rs use crate::actor::{Actor, Configurable}; use crate::address::Address; use crate::bus::EventBus; use crate::device::Device; use crate::prelude::*; pub use crate::hal::uart::Error; use crate::hal::uart::Uart as HalUart; use crate::interrupt::{...
code_fim
hard
{ "lang": "rust", "repo": "placrosse/drogue-device", "path": "/src/driver/uart/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elizlotto/relay path: /compiler/crates/graphql-syntax/src/lib.rs /* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #![deny(warnings)] #![deny(rust_2018_idiom...
code_fim
hard
{ "lang": "rust", "repo": "elizlotto/relay", "path": "/compiler/crates/graphql-syntax/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn parse_type( source: &str, source_location: SourceLocationKey, ) -> DiagnosticsResult<TypeAnnotation> { let features = ParserFeatures::default(); let parser = Parser::new(source, source_location, features); parser.parse_type() }<|fim_prefix|>// repo: elizlotto/relay path: /compi...
code_fim
hard
{ "lang": "rust", "repo": "elizlotto/relay", "path": "/compiler/crates/graphql-syntax/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swipswaps/rpfm path: /rpfm_lib/src/common/decoder.rs ing + zeros). fn decode_string_u16_0padded(&self, offset: usize, size: usize) -> Result<(String, usize)>; /// This function allows us to decode a boolean from a byte, moving the provided index to the byte where the next data starts. ...
code_fim
hard
{ "lang": "rust", "repo": "swipswaps/rpfm", "path": "/rpfm_lib/src/common/decoder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swipswaps/rpfm path: /rpfm_lib/src/common/decoder.rs ; /// This function allows us to decode an u16 integer from raw data. fn decode_integer_u16(&self, offset: usize) -> Result<u16>; /// This function allows us to decode an u32 integer from raw data. fn decode_integer_u32(&self...
code_fim
hard
{ "lang": "rust", "repo": "swipswaps/rpfm", "path": "/rpfm_lib/src/common/decoder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.len() >= offset + size && size % 2 == 0 { let u16_characters = self[offset..offset + size].chunks_exact(2).map(|x| u16::from_le_bytes([x[0], x[1]])).collect::<Vec<u16>>(); String::from_utf16(&u16_characters).map_err(|_| Error::from(ErrorKind::HelperDecodingEncodingE...
code_fim
hard
{ "lang": "rust", "repo": "swipswaps/rpfm", "path": "/rpfm_lib/src/common/decoder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eterevsky/gamer-rust path: /src/agents/mcts/report.rs use std::fmt; use crate::def::AgentReport; #[derive(Clone)] pub struct MctsReport<M: fmt::Display + Clone + 'static> { best_move: M, // Total number of playouts. samples: u64, score: f32, // Player, that makes the move. player: ...
code_fim
hard
{ "lang": "rust", "repo": "eterevsky/gamer-rust", "path": "/src/agents/mcts/report.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<M: fmt::Display + Clone + 'static> AgentReport<M> for MctsReport<M> { fn get_move(&self) -> M { self.best_move.clone() } }<|fim_prefix|>// repo: eterevsky/gamer-rust path: /src/agents/mcts/report.rs use std::fmt; use crate::def::AgentReport; #[derive(Clone)] pub struct MctsReport<M: fmt::D...
code_fim
medium
{ "lang": "rust", "repo": "eterevsky/gamer-rust", "path": "/src/agents/mcts/report.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> writeln!( f, "Player {}: {}, score {:.3}, playouts {}", if self.player { 1 } else { 2 }, self.best_move, self.score, self.samples ) } } impl<M: fmt::Display + Clone + 'static> AgentReport<M> for MctsReport<M> { fn get_move(&self) -> M { self.best_move.c...
code_fim
medium
{ "lang": "rust", "repo": "eterevsky/gamer-rust", "path": "/src/agents/mcts/report.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: poetry-book/poetry-book path: /src/core/poem_formatting.rs /// How to format a poem. #[derive(PartialEq, Eq, Debug, Copy, Clone)] pub struct PoemFormatting { centered_verse: CenteredVerse, } impl PoemFormatting { pub fn new(centered_verse: CenteredVerse) -> PoemFormatting { Poem...
code_fim
medium
{ "lang": "rust", "repo": "poetry-book/poetry-book", "path": "/src/core/poem_formatting.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Determine which verse will be centered #[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum CenteredVerse { /// A verse with a number of 'x' equal to the average length among all verses Average, /// The verse with the longest length Longest, }<|fim_prefix|>// repo: poetry-book/poetry-...
code_fim
hard
{ "lang": "rust", "repo": "poetry-book/poetry-book", "path": "/src/core/poem_formatting.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PhilipDaniels/rsforcs path: /examples-rust/src/linq/where_tests.rs mod tests { #[test] fn where1_ints() { let source = vec![1, 2, 3, 4]; // iter() yields &T. filter() takes &T and yields T. // // So in this very common example, iter() yields items of type...
code_fim
hard
{ "lang": "rust", "repo": "PhilipDaniels/rsforcs", "path": "/examples-rust/src/linq/where_tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(result1, vec![1, 3, 4]); } #[test] fn where2_ints_filter_map() { let source = vec![1, 2, 3, 4]; let result : Vec<i32> = source.iter().enumerate() .filter_map(|(idx, &x)| if idx == 0 || x > 2 { Some(x) } else { None }) .collect(); ...
code_fim
medium
{ "lang": "rust", "repo": "PhilipDaniels/rsforcs", "path": "/examples-rust/src/linq/where_tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cffi-rs/cffi path: /src/arc.rs use std::convert::Infallible; use std::error::Error; use std::marker::PhantomData; use std::sync::Arc; use std::mem::MaybeUninit; use crate::TraitObject; use super::null_ptr_error; use super::{FromForeign, InputType, ReturnType, ToForeign}; pub struct ArcMarshal...
code_fim
hard
{ "lang": "rust", "repo": "cffi-rs/cffi", "path": "/src/arc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Arc::from_raw(foreign as *const _)) } } impl<T: ?Sized> ToForeign<Result<Arc<T>, Box<dyn Error>>, *const T> for ArcMarshaler<T> { type Error = Box<dyn Error>; #[inline(always)] fn to_foreign(local: Result<Arc<T>, Box<dyn Error>>) -> Result<*const T, Self::Error> { loca...
code_fim
hard
{ "lang": "rust", "repo": "cffi-rs/cffi", "path": "/src/arc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CNife/leetcode path: /rust/finished/src/split_a_string_in_balanced_strings.rs pub fn balanced_string_split(s: impl AsRef<str>) -> i32 { let mut flag = 0; let mut cnt = 0; for ch in s.as_ref().bytes() { flag += match ch { b'L' => 1, b'R' => -1, ...
code_fim
medium
{ "lang": "rust", "repo": "CNife/leetcode", "path": "/rust/finished/src/split_a_string_in_balanced_strings.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cases = vec![("RLRRLLRLRL", 4), ("RLLLLRRRLR", 3), ("LLLLRRRR", 1)]; for (input, expected) in cases { let output = balanced_string_split(input); assert_eq!(output, expected); } }<|fim_prefix|>// repo: CNife/leetcode path: /rust/finished/src/split_a_string_in_balanced_strin...
code_fim
medium
{ "lang": "rust", "repo": "CNife/leetcode", "path": "/rust/finished/src/split_a_string_in_balanced_strings.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = repo::CoinDominanceRepo::find_by_timestamp_rounded(ts, db.get_ref()) .await; let data = match result { Ok(x) => x, Err(e) => return e.to_response(), }; let response = CoinDominanceResponse { status: ResponseStatus::Success, ...
code_fim
hard
{ "lang": "rust", "repo": "EdsonAlcala/coingecko-cache", "path": "/domfi_api/src/api/routes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EdsonAlcala/coingecko-cache path: /domfi_api/src/api/routes.rs use actix_web::{Responder, HttpResponse, web, get}; use chrono::{Utc, NaiveDateTime, DateTime}; use sqlx::PgPool; use uuid::Uuid; use bigdecimal::BigDecimal; use crate::{repo, convert}; use crate::api::convert::ToResponse; use crate:...
code_fim
hard
{ "lang": "rust", "repo": "EdsonAlcala/coingecko-cache", "path": "/domfi_api/src/api/routes.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: romainlom1843/Dropvaultv3 path: /DropVault/Dropvault-stockage/stockage/src/files.rs use super::models::{NewFile, File}; use super::schema::files::dsl::*; use super::Pool; use crate::diesel::QueryDsl; use crate::diesel::RunQueryDsl; use actix_web::{web, Error, HttpResponse, Responder}; use diesel...
code_fim
hard
{ "lang": "rust", "repo": "romainlom1843/Dropvaultv3", "path": "/DropVault/Dropvault-stockage/stockage/src/files.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } fn db_download(pool: web::Data<Pool>, file_id: i32) -> Result<File, diesel::result::Error> { let conn = pool.get().unwrap(); files.find(file_id).get_result::<File>(&conn) } pub async fn dwl_content(file_id: web::Path<i32>)-> impl Responder{ let path = "../stock/";...
code_fim
hard
{ "lang": "rust", "repo": "romainlom1843/Dropvaultv3", "path": "/DropVault/Dropvault-stockage/stockage/src/files.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hanselrd/dotfiles path: /ancestry/vnext/dotfiles-core/src/generator.rs // use handlebars::Handlebars; use std::collections::HashMap; use std::path::PathBuf; #[derive(Debug, Default)] pub struct Generator { pub tasks: HashMap<dft::Role, Vec<dfa::Task>>, // add commands <|fim_suffix|>// ...
code_fim
hard
{ "lang": "rust", "repo": "hanselrd/dotfiles", "path": "/ancestry/vnext/dotfiles-core/src/generator.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>// use handlebars::Handlebars; // pub fn example_handlebars(config: &dft::Configuration) { // let mut handlebars = Handlebars::new(); // handlebars.set_strict_mode(true); // handlebars.register_template_file("hello", "dotfiles-core/src/roles/common/files/hello.hbs") // .unwrap(); // prin...
code_fim
hard
{ "lang": "rust", "repo": "hanselrd/dotfiles", "path": "/ancestry/vnext/dotfiles-core/src/generator.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> policy_data: &PolicyData, proposed_install_plan: &impl Plan, ) -> UpdateDecision; } pub trait PolicyEngine { /// When should the next update happen? fn compute_next_update_time( &mut self, apps: &[App], scheduling: &UpdateCheckSchedule, protocol...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/garnet/lib/rust/omaha_client/src/policy.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Given the current State, the current PolicyData, can the proposed InstallPlan /// be executed at this time. fn update_can_start( policy_data: &PolicyData, proposed_install_plan: &impl Plan, ) -> UpdateDecision; } pub trait PolicyEngine { /// When should the next up...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/garnet/lib/rust/omaha_client/src/policy.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: winksaville/fuchsia path: /garnet/lib/rust/omaha_client/src/policy.rs // Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use crate::{ common::{App, CheckOptions, ProtocolState, U...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/garnet/lib/rust/omaha_client/src/policy.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> Ok(format!("Updated to {}", description)) } } pub fn move_to( &self, branch: &mut git2::Branch, repo: &git2::Repository, commit: &git2::Commit, ) -> Result<(), git2::Error> { // This seems like the wrong order (first we checkout the content, then update the branch) ...
code_fim
medium
{ "lang": "rust", "repo": "speveril/orisa", "path": "/server/src/repo.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: speveril/orisa path: /server/src/repo.rs use git2; use std::path::{Path, PathBuf}; #[derive(Clone)] pub struct Repo { root: PathBuf, remote_name: String, branch_name: String, } impl Repo { pub fn new(root: &Path, remote_name: String, branch_name: String) -> Repo { let root = root.t...
code_fim
hard
{ "lang": "rust", "repo": "speveril/orisa", "path": "/server/src/repo.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /* ifaces.iter_mut() .zip(patchbays.iter_mut()) .enumerate() .for_each(|(i, (iface, pb))| { let mut iface = iface.write().unwrap(); let mut pb = pb.write().unwrap(); iface.inputs.iter_mut() .zip(pb.outputs[NUM_INTERCONNECT...
code_fim
hard
{ "lang": "rust", "repo": "thavlik/paradise", "path": "/scout/src/test/pathfinding/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thavlik/paradise path: /scout/src/test/pathfinding/mod.rs use super::*; #[test] fn basic() { const NUM_PATCHBAYS: usize = 3; const NUM_CHANNELS: usize = 32; const NUM_INTERCONNECT_CHANNELS: usize = 4; let mut patchbays: Vec<Box<Node>> = (0..NUM_PATCHBAYS) .map(|_| Node::...
code_fim
hard
{ "lang": "rust", "repo": "thavlik/paradise", "path": "/scout/src/test/pathfinding/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jfhansen/s32k144.rs path: /src/dma.rs nking Enabled)"] #[inline(always)] pub fn tcd2_citer_elinkyes_mut(&self) -> &mut TCD_CITER_ELINKYES { unsafe { &mut *(((self as *const Self) as *mut u8).add(4182usize) as *mut TCD_CITER_ELINKYES) } } #[doc = "0x1056 - TCDn Current Min...
code_fim
hard
{ "lang": "rust", "repo": "jfhansen/s32k144.rs", "path": "/src/dma.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[doc = "0x1116 - TCDn Current Minor Loop Link, Major Loop Count (Channel Linking Disabled)"] #[inline(always)] pub fn tcd8_citer_elinkno(&self) -> &TCD_CITER_ELINKNO { unsafe { &*(((self as *const Self) as *const u8).add(4374usize) as *const TCD_CITER_ELINKNO) } } #[doc = "0x1...
code_fim
hard
{ "lang": "rust", "repo": "jfhansen/s32k144.rs", "path": "/src/dma.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>CHPRI0 {} #[doc = "`write(|w| ..)` method takes [dchpri0::W](dchpri0::W) writer structure"] impl crate::Writable for DCHPRI0 {} #[doc = "Channel n Priority Register"] pub mod dchpri0; #[doc = "Channel n Priority Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generi...
code_fim
hard
{ "lang": "rust", "repo": "jfhansen/s32k144.rs", "path": "/src/dma.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let v:Vec<&str> = body.split(',').collect(); if v.is_empty() { return false; } let command = v.get(0).unwrap(); println!("{:?}", command); if *command == "speed" { *self = Protocol::Speed((0f32,0f32)); } if *command == "chat" { ...
code_fim
hard
{ "lang": "rust", "repo": "mas-yo/ragtime-old", "path": "/ragtime_sample1/src/command.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mas-yo/ragtime-old path: /ragtime_sample1/src/command.rs use std::io::BufRead; use std::str::FromStr; use ragtime::network::Serialize; #[derive(Debug)] pub enum Command { None, C2S_RequestUIInfo{ ui_id:u32 }, S2C_ResponseUIInfo{ info: String }, C2S_Submit{ ui_id:u32, info: Stri...
code_fim
medium
{ "lang": "rust", "repo": "mas-yo/ragtime-old", "path": "/ragtime_sample1/src/command.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seed-rs/seed path: /examples/el_key/src/lib.rs //! This example shows how to control a DOM update using element keys and empty nodes. //! See README.md for more details. use gloo_console::log; use rand::{rngs::SmallRng, seq::SliceRandom, SeedableRng}; use regex::Regex; use scarlet::{ color:...
code_fim
hard
{ "lang": "rust", "repo": "seed-rs/seed", "path": "/examples/el_key/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn swap(cards: &mut [Card], a_id: CardId, b_id: CardId) { if let (Some(a_index), Some(b_index)) = (card_index(cards, a_id), card_index(cards, b_id)) { cards.swap(a_index, b_index); } } fn card_index(cards: &[Card], card_id: CardId) -> Option<usize> { cards .iter() .enu...
code_fim
hard
{ "lang": "rust", "repo": "seed-rs/seed", "path": "/examples/el_key/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bowd/celo-bls-snark-rs path: /crates/epoch-snark/tests/e2e.rs use epoch_snark::{prove, trusted_setup, verify}; mod fixtures; use fixtures::generate_test_data; #[test] #[ignore] // This test makes CI run out of memory and takes too long. It works though! fn prover_verifier_groth16() { <|fim_suf...
code_fim
hard
{ "lang": "rust", "repo": "bowd/celo-bls-snark-rs", "path": "/crates/epoch-snark/tests/e2e.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Verifier checks the proof let res = verify(&params.epochs.vk, &first_epoch, &last_epoch, &proof); assert!(res.is_ok()); }<|fim_prefix|>// repo: bowd/celo-bls-snark-rs path: /crates/epoch-snark/tests/e2e.rs use epoch_snark::{prove, trusted_setup, verify}; mod fixtures; use fixtures::genera...
code_fim
hard
{ "lang": "rust", "repo": "bowd/celo-bls-snark-rs", "path": "/crates/epoch-snark/tests/e2e.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: relab/libra-bbchain-port path: /client/json-rpc/src/lib.rs // Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 <|fim_suffix|>pub mod errors; pub mod views; pub use blocking::JsonRpcClient; pub use client::{ get_response_from_batch, process_batch_response, Js...
code_fim
easy
{ "lang": "rust", "repo": "relab/libra-bbchain-port", "path": "/client/json-rpc/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }