text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: AngleOSaxon/NodeSSPI path: /native/bindings.rs /* automatically generated by rust-bindgen */ #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { #[inline] pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } ...
code_fim
hard
{ "lang": "rust", "repo": "AngleOSaxon/NodeSSPI", "path": "/native/bindings.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(::std::mem::size_of::<_SecHandle>() , 16usize , concat ! ( "Size of: " , stringify ! ( _SecHandle ) )); assert_eq! (::std::mem::align_of::<_SecHandle>() , 8usize , concat ! ( "Alignment of " , stringify ! ( _SecHandle ) )); assert_eq! (unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "AngleOSaxon/NodeSSPI", "path": "/native/bindings.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KaoImin/rbatis path: /rbatis-macro-driver/src/util.rs use std::collections::HashMap; use proc_macro2::{Ident, Span}; use quote::quote; use quote::ToTokens; use syn; use syn::{FnArg, ItemFn, ReturnType}; //find and check method return type pub(crate) fn find_return_type(target_fn: &ItemFn) -> p...
code_fim
hard
{ "lang": "rust", "repo": "KaoImin/rbatis", "path": "/rbatis-macro-driver/src/util.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn filter_fn_args( target_fn: &ItemFn, arg_name: &str, arg_type: &str, ) -> std::collections::HashMap<String, String> { let mut map = HashMap::new(); for arg in &target_fn.sig.inputs { match arg { FnArg::Typed(t) => { let arg_name_value = ...
code_fim
hard
{ "lang": "rust", "repo": "KaoImin/rbatis", "path": "/rbatis-macro-driver/src/util.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>//find and check method return type pub(crate) fn find_fn_body(target_fn: &ItemFn) -> proc_macro2::TokenStream { //del todos let mut target_fn = target_fn.clone(); let mut new_stmts =vec![]; for x in &target_fn.block.stmts { let token=x.to_token_stream().to_string().replace("\n",""...
code_fim
hard
{ "lang": "rust", "repo": "KaoImin/rbatis", "path": "/rbatis-macro-driver/src/util.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nmandery/h3r path: /h3/src/geo.rs #[cfg(feature = "with-geo-types-0_4")] use geo_types_04::{Coordinate, LineString, Point}; #[cfg(feature = "with-geo-types-0_6")] use geo_types_06::{Coordinate, LineString, Point}; <|fim_suffix|>pub(crate) unsafe fn point_to_geocoord(pt: &Point<f64>) -> GeoCoord...
code_fim
hard
{ "lang": "rust", "repo": "nmandery/h3r", "path": "/h3/src/geo.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) unsafe fn point_to_geocoord(pt: &Point<f64>) -> GeoCoord { GeoCoord { lat: degsToRads(pt.y()), lon: degsToRads(pt.x()), } }<|fim_prefix|>// repo: nmandery/h3r path: /h3/src/geo.rs #[cfg(feature = "with-geo-types-0_4")] use geo_types_04::{Coordinate, LineString, Point}; ...
code_fim
hard
{ "lang": "rust", "repo": "nmandery/h3r", "path": "/h3/src/geo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) unsafe fn linestring_to_geocoords(ls: &LineString<f64>) -> Vec<GeoCoord> { ls.points_iter() .map(|p| point_to_geocoord(&p)) .collect() } pub(crate) unsafe fn point_to_geocoord(pt: &Point<f64>) -> GeoCoord { GeoCoord { lat: degsToRads(pt.y()), lon: degsT...
code_fim
medium
{ "lang": "rust", "repo": "nmandery/h3r", "path": "/h3/src/geo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matter-labs/franklin-crypto path: /src/plonk/circuit/multieq.rs use crate::bellman::pairing::{ Engine, }; use crate::bellman::pairing::ff::{ Field, PrimeField, PrimeFieldRepr, BitIterator }; use crate::bellman::{ SynthesisError, }; use crate::bellman::plonk::better_bet...
code_fim
hard
{ "lang": "rust", "repo": "matter-labs/franklin-crypto", "path": "/src/plonk/circuit/multieq.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> self.lhs.add_assign(&scaled_lhs); self.rhs.add_assign(&scaled_rhs); self.bits_used += num_bits; } } impl<'a, E: Engine, CS: ConstraintSystem<E> + 'a> Drop for MultiEq<'a, E, CS> { fn drop(&mut self) { if self.bits_used > 0 { self.accumulate(); }...
code_fim
hard
{ "lang": "rust", "repo": "matter-labs/franklin-crypto", "path": "/src/plonk/circuit/multieq.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SuperCuber/rmenu path: /src/config.rs use conrod::color::{self, Color}; #[doc = "Configuration for the GUI. Check source for what the defaults are. **Note**: ALWAYS add `..Default::default()` when creating a Config since I may add more configuration options and I will consider it a non breakin...
code_fim
hard
{ "lang": "rust", "repo": "SuperCuber/rmenu", "path": "/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> input_top_padding: 0.0, output_top_padding: 0.0, font: "/usr/share/fonts/TTF/Ubuntu-M.ttf".into(), disable_esc: false, } } }<|fim_prefix|>// repo: SuperCuber/rmenu path: /src/config.rs use conrod::color::{self, Color}; #[doc = "Configuration ...
code_fim
hard
{ "lang": "rust", "repo": "SuperCuber/rmenu", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cisen/sericum path: /tests/assembler.rs #[cfg(feature = "x86_64")] mod x86_64 { use sericum::{ codegen::x64::{ asm::assembler::Assembler, exec::executor::{Executor, GenericValue}, standard_conversion_into_machine_module, }, ir::{/*g...
code_fim
hard
{ "lang": "rust", "repo": "cisen/sericum", "path": "/tests/assembler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn asmer_jit_call() { let mut m = Module::new("sericum"); sericum_ir!(m; define [i32] add [(i32)] { entry: x = add (%arg.0), (i32 2); ret (%x); }); sericum_ir!(m; define [i32] main [(i32)] { entry: x = call add [(%...
code_fim
hard
{ "lang": "rust", "repo": "cisen/sericum", "path": "/tests/assembler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rustup path: /src/dist/triple.rs use lazy_static::lazy_static; use regex::Regex; // These lists contain the targets known to rustup, and used to build // the PartialTargetTriple. static LIST_ARCHS: &[&str] = &[ "i386", "i586", "i686", "x86_64", "arm", "armv7",...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustup", "path": "/src/dist/triple.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for (input, (arch, os, env)) in success_cases { let partial_target_triple = PartialTargetTriple::new(input); assert!( partial_target_triple.is_some(), "expected `{input}` to create some partial target triple; got None" ); ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustup", "path": "/src/dist/triple.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub enum Direction { North, South, West, East, } impl Direction { pub fn turn_left(self: Self) -> Self { match self { Self::North => Self::West, Self::West => Self::South, Self::South => Self::East, Self::East =>...
code_fim
hard
{ "lang": "rust", "repo": "claudiomattera/advanced-langton-ant", "path": "/src/board.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: claudiomattera/advanced-langton-ant path: /src/board.rs // Copyright Claudio Mattera 2020. // Distributed under the MIT License. // See accompanying file License.txt, or online at // https://opensource.org/licenses/MIT use log::*; use std::error; use std::fmt; use image::{ImageBuffer, Rgba, R...
code_fim
hard
{ "lang": "rust", "repo": "claudiomattera/advanced-langton-ant", "path": "/src/board.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(IoUring { fd, flags, sq, cq, memory: ManuallyDrop::new(mm) }) } pub unsafe fn register(&self, target: reg::Target<'_>) -> io::Result<()> { let (opcode, arg, len) = target.export(); if 0 == sys::io_uring_register(self.fd.as_raw_fd(), opco...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/linux-io-uring", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok((mm, sq, cq)) } else { let sq_mmap = Mmap::new(fd, sys::IORING_OFF_SQ_RING as _, sq_len)?; let cq_mmap = Mmap::new(fd, sys::IORING_OFF_CQ_RING as _, cq_len)?; let sq = SubmissionQueue::new(&sq_mmap, &sqe_mmap, p); ...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/linux-io-uring", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Atul9/linux-io-uring path: /src/lib.rs mod util; mod register; pub mod squeue; pub mod cqueue; pub mod opcode; pub mod concurrent; use std::{ io, ptr, cmp, mem }; use std::convert::TryInto; use std::os::unix::io::{ AsRawFd, RawFd }; use std::mem::ManuallyDrop; use bitflags::bitflags; use linux_...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/linux-io-uring", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swallez/tasques path: /example/ciphers/worker-rs/client/src/models/task_claim.rs /* * Tasques API * * A Task queue backed by Elasticsearch * * The version of the OpenAPI document: 0.0.1 * * Generated by: https://openapi-generator.tech */ <|fim_suffix|>impl TaskClaim { pub fn new(que...
code_fim
hard
{ "lang": "rust", "repo": "swallez/tasques", "path": "/example/ciphers/worker-rs/client/src/models/task_claim.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl TaskClaim { pub fn new(queues: Vec<String>) -> TaskClaim { TaskClaim { amount: None, block_for: None, queues, } } }<|fim_prefix|>// repo: swallez/tasques path: /example/ciphers/worker-rs/client/src/models/task_claim.rs /* * Tasques API * ...
code_fim
hard
{ "lang": "rust", "repo": "swallez/tasques", "path": "/example/ciphers/worker-rs/client/src/models/task_claim.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alextanhongpin/rust-postgres path: /src/models/person.rs // #[macro_use] extern crate serde_derive; // #[macro_use] extern crate serde_js<|fim_suffix|>ug, Serialize, Deserialize)] pub struct Person { pub id: Uuid, pub name: String, pub data: Option<serde_json::Value>, pub previous_time: ...
code_fim
medium
{ "lang": "rust", "repo": "alextanhongpin/rust-postgres", "path": "/src/models/person.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ug, Serialize, Deserialize)] pub struct Person { pub id: Uuid, pub name: String, pub data: Option<serde_json::Value>, pub previous_time: DateTime<Utc>, }<|fim_prefix|>// repo: alextanhongpin/rust-postgres path: /src/models/person.rs // #[macro_use] extern crate serde_derive; // #[macro_use] exter...
code_fim
medium
{ "lang": "rust", "repo": "alextanhongpin/rust-postgres", "path": "/src/models/person.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dsboo/study-rust path: /while_/src/main.rs fn main() { let mut x = 5; // mut x: i32 let mut done = false; // mut done: bool while !done { x += x - 3; <|fim_suffix|> if x % 5 == 0 { break; } } for x in 0..10 { if x % 2 == 0 { continue; } println!("...
code_fim
medium
{ "lang": "rust", "repo": "dsboo/study-rust", "path": "/while_/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for x in 0..10 { if x % 2 == 0 { continue; } println!("{}", x); } println!("Hello, world!"); }<|fim_prefix|>// repo: dsboo/study-rust path: /while_/src/main.rs fn main() { let mut x = 5; // mut x: i32 let mut done = false; // mut done: bool while !done { x += x - 3; println!("{}",...
code_fim
medium
{ "lang": "rust", "repo": "dsboo/study-rust", "path": "/while_/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jugeeya/UltimateTrainingModpack path: /src/training/throw.rs use smash::app::{self, lua_bind::*}; use smash::lib::lua_const::*; use crate::common::consts::*; use crate::common::*; use crate::training::frame_counter; use crate::training::mash; const NOT_SET: u32 = 9001; static mut THROW_DELAY: ...
code_fim
hard
{ "lang": "rust", "repo": "jugeeya/UltimateTrainingModpack", "path": "/src/training/throw.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> roll_pummel_delay(); if THROW_CASE == ThrowOption::NONE { // Do nothing, but don't reroll the throw case. return 0; } if frame_counter::should_delay(THROW_DELAY, THROW_DELAY_COUNTER) { // Not yet time to perform the throw action if frame_counter::should_de...
code_fim
hard
{ "lang": "rust", "repo": "jugeeya/UltimateTrainingModpack", "path": "/src/training/throw.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> info!("Dropping remote peer: {}", self.id); } } // Takes incoming messages from `rx` and sends them out via the network // interface for the specified peer. fn remote_peer_send_loop( id: ID, stream: TcpStream, rx: channel::Receiver<PeerMessage>, node_channel: channel::Sender<E...
code_fim
hard
{ "lang": "rust", "repo": "informalsystems/reactor-experiments", "path": "/singlethreaded/blocking/src/remote_peer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: informalsystems/reactor-experiments path: /singlethreaded/blocking/src/remote_peer.rs //! //! Tendermint peer-related functionality. //! //! Assumes a synchronous, blocking networking model that employs threads to //! handle peer connectivity. //! use crossbeam::channel; use log::info; use std:...
code_fim
hard
{ "lang": "rust", "repo": "informalsystems/reactor-experiments", "path": "/singlethreaded/blocking/src/remote_peer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// Blocks on incoming connections to `writer` fn remote_peer_receive_loop( id: ID, stream: TcpStream, node_channel: channel::Sender<Event>, ) -> Result<(), RemotePeerError> { let mut reader = BufReader::new(stream); loop { match reader.read_peer_message() { Ok(msg) ...
code_fim
hard
{ "lang": "rust", "repo": "informalsystems/reactor-experiments", "path": "/singlethreaded/blocking/src/remote_peer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ThomasZumsteg/adventofcode2018 path: /day12.rs extern crate common; use std::collections::HashMap; use regex::Regex; type Pot = char; #[derive(Clone)] struct Pots { mapping: HashMap<String, char>, slots: HashMap<isize, Pot> } impl Pots { fn new(pots: &mut Iterator<Item=char>, map...
code_fim
hard
{ "lang": "rust", "repo": "ThomasZumsteg/adventofcode2018", "path": "/day12.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn part2(start: &Pots) -> isize { let mut pots = start.clone(); let mut countdown: usize = 50000000000; let mut prev: Option<String> = None; while countdown > 0 && prev != Some(pots.to_string()) { prev = Some(pots.to_string()); pots.next(); countdown -= 1; } ...
code_fim
hard
{ "lang": "rust", "repo": "ThomasZumsteg/adventofcode2018", "path": "/day12.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PacktPublishing/The-Complete-Rust-Programming-Reference-Guide path: /Chapter01/functions.rs // functions.rs fn add(a: u64, b: u64) -> u64 { <|fim_suffix|> let a: u64 = 17; let b = 3; let result = add(a, b); println!("Result {}", result); }<|fim_middle|> a + b } fn main() {
code_fim
easy
{ "lang": "rust", "repo": "PacktPublishing/The-Complete-Rust-Programming-Reference-Guide", "path": "/Chapter01/functions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let a: u64 = 17; let b = 3; let result = add(a, b); println!("Result {}", result); }<|fim_prefix|>// repo: PacktPublishing/The-Complete-Rust-Programming-Reference-Guide path: /Chapter01/functions.rs // functions.rs fn add(a: u64, b: u64) -> u64 { a + b } <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "PacktPublishing/The-Complete-Rust-Programming-Reference-Guide", "path": "/Chapter01/functions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dotcypress/fpgb path: /firmware/src/matrix.rs use hal::hal::blocking::delay::DelayUs; use hal::hal::digital::v2::OutputPin; pub struct SwitchMatrix< D, RST, STROBE, DATA, AX0, AX1, AX2, AX3, AY0, AY1, AY2, CS0, CS1, CS2, CS3, CS4, ...
code_fim
hard
{ "lang": "rust", "repo": "dotcypress/fpgb", "path": "/firmware/src/matrix.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(chip_idx < 5 && x < 16 && y < 8); self.cs0.set_low()?; self.cs1.set_low()?; self.cs2.set_low()?; self.cs3.set_low()?; self.cs4.set_low()?; match chip_idx { 0 => self.cs0.set_high()?, 1 => self.cs1.set_high()?, ...
code_fim
hard
{ "lang": "rust", "repo": "dotcypress/fpgb", "path": "/firmware/src/matrix.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: semio-ai/drydoc path: /crates/drydoc-gen/src/config.rs use serde::{Serialize, Deserialize}; use super::page::Id; use std::collections::HashMap; <|fim_suffix|>#[derive(Serialize, Deserialize, Debug)] pub struct Unit { pub id: Id, pub name: String, pub rule: Rule, pub children: Option<Ve...
code_fim
medium
{ "lang": "rust", "repo": "semio-ai/drydoc", "path": "/crates/drydoc-gen/src/config.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)] pub struct Import { pub uri: String } #[derive(Serialize, Deserialize, Debug)] #[serde(tag = "type", rename_all = "lowercase")] pub enum Decl { Unit(Unit), Import(Import) } #[derive(Serialize, Deserialize, Debug)] pub struct Config { pub decl: Decl }<|fim...
code_fim
hard
{ "lang": "rust", "repo": "semio-ai/drydoc", "path": "/crates/drydoc-gen/src/config.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)] pub struct Config { pub decl: Decl }<|fim_prefix|>// repo: semio-ai/drydoc path: /crates/drydoc-gen/src/config.rs use serde::{Serialize, Deserialize}; use super::page::Id; use std::collections::HashMap; #[derive(Serialize, Deserialize, Debug)] pub struct Rule ...
code_fim
hard
{ "lang": "rust", "repo": "semio-ai/drydoc", "path": "/crates/drydoc-gen/src/config.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> "[function define-and-call-fn]"; "(define-and-call-fn :x 1 :y 2 :z 3)" => "1"; "(define-and-call-fn :z 3 :y 2 :x 1)" => "1"; "(define-and-call-fn :z 3)" => "3"; "(define-and-call-fn :y 2 :z 3)" => "2"; } }<|fim_prefix|>// repo: gefjon/phoebe path: /tests/key_args.rs #...
code_fim
medium
{ "lang": "rust", "repo": "gefjon/phoebe", "path": "/tests/key_args.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> :y 2 :x 1)" => "1"; "(define-and-call-fn :z 3)" => "3"; "(define-and-call-fn :y 2 :z 3)" => "2"; } }<|fim_prefix|>// repo: gefjon/phoebe path: /tests/key_args.rs #[macro_use] extern crate phoebe; #[test] fn define_and_call() { test_pairs! { "(defun define-and-call-fn (&<...
code_fim
hard
{ "lang": "rust", "repo": "gefjon/phoebe", "path": "/tests/key_args.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gefjon/phoebe path: /tests/key_args.rs #[macro_use] extern crate phoebe; #[test] fn define_and_call() { test_pairs! { "(defun define-and-call-fn (&key x y z) \ (cond \ (x x) \ (y y) \ (z z) \ (t nil)))" =><|fim_suffix|> ...
code_fim
medium
{ "lang": "rust", "repo": "gefjon/phoebe", "path": "/tests/key_args.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self, specifier: &str, referrer: &str, is_main: bool, ) -> Result<ModuleSpecifier, ErrBox> { if !is_main { if let Some(import_map) = &self.import_map { let result = import_map.resolve(specifier, referrer)?; if let Some(r) = result { return Ok(r); ...
code_fim
hard
{ "lang": "rust", "repo": "piscisaureus/deno", "path": "/cli/state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: piscisaureus/deno path: /cli/state.rs e std::path::Path; use std::pin::Pin; use std::rc::Rc; use std::str; use std::sync::Arc; use std::thread::JoinHandle; use std::time::Instant; #[cfg_attr(feature = "cargo-clippy", allow(stutter))] pub struct State { pub global_state: Arc<GlobalState>, pu...
code_fim
hard
{ "lang": "rust", "repo": "piscisaureus/deno", "path": "/cli/state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let result = dispatcher(&state, &mut *resource_table.borrow_mut(), args, zero_copy); // Convert to Op. Op::Sync(serialize_result(None, result)) } } pub fn stateful_json_op_async<D, F>( self: &Rc<Self>, resource_table: &Rc<RefCell<ResourceTable>>, dispatcher:...
code_fim
hard
{ "lang": "rust", "repo": "piscisaureus/deno", "path": "/cli/state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// What type ? Are these integers? Floats? // Positive and negative alike? // Max value? // Max length? // Solution 1 // Fold the multiply operator over the array //fn product_in_place(elements: &Vec<i32>) -> Vec<i32> { // let max_product = elements.iter().fold(1, |product, i| product * i); // elem...
code_fim
hard
{ "lang": "rust", "repo": "gulbrand/learning-rust", "path": "/src/bin/multiple_arrays.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// Solution 1 // Fold the multiply operator over the array //fn product_in_place(elements: &Vec<i32>) -> Vec<i32> { // let max_product = elements.iter().fold(1, |product, i| product * i); // elements.iter().map(|i| product / i) //// elements.iter().map(|i| productr / i).as_slice() // // //} fn m...
code_fim
hard
{ "lang": "rust", "repo": "gulbrand/learning-rust", "path": "/src/bin/multiple_arrays.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gulbrand/learning-rust path: /src/bin/multiple_arrays.rs /** Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our input was [1, 2, 3, 4, 5], the expected...
code_fim
medium
{ "lang": "rust", "repo": "gulbrand/learning-rust", "path": "/src/bin/multiple_arrays.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let msg_res = Msg::read(&mut bytes); self.state = MsgRxState::Unpacking(bytes); Ok(Async::Ready(Some((msg_res, addr)))) }, } } } }<|fim_prefix|>// repo: c410-f3r/lightstore path: /lightstore/src/daemon/pee...
code_fim
hard
{ "lang": "rust", "repo": "c410-f3r/lightstore", "path": "/lightstore/src/daemon/peer/msg_rx.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: c410-f3r/lightstore path: /lightstore/src/daemon/peer/msg_rx.rs pub struct MsgRx { socket: SharedUdpSocket, state: MsgRxState, peer_db: Arc<PeerDb>, } enum MsgRxState { Invalid, Waiting, Receiving(lightstore_shared_udp_socket::RecvDgram), Unpacking(Cursor<Bytes>), } ...
code_fim
hard
{ "lang": "rust", "repo": "c410-f3r/lightstore", "path": "/lightstore/src/daemon/peer/msg_rx.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nuc1eoN/SteamHelper-rs path: /crates/steam-protobuf/src/steam/steamnetworkingsockets_messages.rs self.packets_recv = ::std::option::Option::Some(is.read_uint64()?); }, 6 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { ...
code_fim
hard
{ "lang": "rust", "repo": "Nuc1eoN/SteamHelper-rs", "path": "/crates/steam-protobuf/src/steam/steamnetworkingsockets_messages.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn has_quality_histogram_75(&self) -> bool { self.quality_histogram_75.is_some() } // Param is passed by value, moved pub fn set_quality_histogram_75(&mut self, v: u32) { self.quality_histogram_75 = ::std::option::Option::Some(v); } // optional uint32 quality_...
code_fim
hard
{ "lang": "rust", "repo": "Nuc1eoN/SteamHelper-rs", "path": "/crates/steam-protobuf/src/steam/steamnetworkingsockets_messages.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>oc_str = if doc.len() > 0 { format!("/**\n *{}\n **/\n", doc.join("\n *")) } else { String::new() }; doc_str }<|fim_prefix|>// repo: sno2/deno_bindgen path: /deno_bindgen_macro/src/docs.rs use syn::Attribute; use syn::Lit; use syn::Meta; pub fn get_docs(attrs: &Vec<Attribute>) -> Strin...
code_fim
hard
{ "lang": "rust", "repo": "sno2/deno_bindgen", "path": "/deno_bindgen_macro/src/docs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sno2/deno_bindgen path: /deno_bindgen_macro/src/docs.rs use syn::Attribute; use syn::Lit; use syn::Meta; pub fn get_docs(attrs: &Vec<Attribute>) -> String { let mut doc: Vec<String> = vec![]; for attr in attrs { if let Ok(Meta::NameValue(meta)) = attr.parse_meta() { if !meta.path....
code_fim
medium
{ "lang": "rust", "repo": "sno2/deno_bindgen", "path": "/deno_bindgen_macro/src/docs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>) { continue; } if let Lit::Str(lit) = meta.lit { doc.push(lit.value()); } } } let doc_str = if doc.len() > 0 { format!("/**\n *{}\n **/\n", doc.join("\n *")) } else { String::new() }; doc_str }<|fim_prefix|>// repo: sno2/deno_bindgen path: /de...
code_fim
medium
{ "lang": "rust", "repo": "sno2/deno_bindgen", "path": "/deno_bindgen_macro/src/docs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NathanaelV/Rust path: /ch03/christmas/src/main.rs fn main() { println!("\nTHE TWELVE DAYS OF CHRISTMAS\n"); let td = [ "", "", "", "", "", "", "", "", "", "", "", "\nAnd a partridge in a pear tree", "\nTwo turtles doves", "\nThree French hens", "\nFour calling bir...
code_fim
hard
{ "lang": "rust", "repo": "NathanaelV/Rust", "path": "/ch03/christmas/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("In my {}º day of Christmas", (i+1)); println!("My true love send to me"); println!("A partridge in a pear tree\n"); i = i + 1 } else {} while i < 12 { println!("In my {}º day of Christmas", (i+1)); print!("My true love send to...
code_fim
hard
{ "lang": "rust", "repo": "NathanaelV/Rust", "path": "/ch03/christmas/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cbrewster/brewblog path: /src/page.rs //! Reads in a page and outputs markdown and metadata use crate::build::BuildContext; use anyhow::{anyhow, Context, Result}; use chrono::NaiveDate; use serde_derive::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; const META_TAG: &'static str = "...
code_fim
hard
{ "lang": "rust", "repo": "cbrewster/brewblog", "path": "/src/page.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let file_name = match path.file_name() { Some(file_name) => file_name.to_string_lossy().to_string(), None => return Err(anyhow!("Failed to get file name for path: {:?}", path)), }; let slug = file_meta.slug.unwrap_or(file_name); let out_path = conte...
code_fim
hard
{ "lang": "rust", "repo": "cbrewster/brewblog", "path": "/src/page.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let link: String = out_path .strip_prefix(&context.output_dir)? .parent() .and_then(|p| p.to_str()) .context("Failed to generate link")? .into(); let metadata = PageMetadata { title: file_meta.title, autho...
code_fim
hard
{ "lang": "rust", "repo": "cbrewster/brewblog", "path": "/src/page.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> loop { fuzz!(|data: &[u8]| { if data.len() > 0 { let _ = PacketParser::from_bytes(data); } }); } }<|fim_prefix|>// repo: alexanderkjall/sequoia-hongg path: /src/main.rs #[macro_use] extern crate honggfuzz; use sequoia_openpgp::parse::{Parse...
code_fim
easy
{ "lang": "rust", "repo": "alexanderkjall/sequoia-hongg", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexanderkjall/sequoia-hongg path: /src/main.rs #[macro_use] extern crate honggfuzz; use sequoia_openpgp::parse::{Parse, PacketParser}; <|fim_suffix|> loop { fuzz!(|data: &[u8]| { if data.len() > 0 { let _ = PacketParser::from_bytes(data); } ...
code_fim
easy
{ "lang": "rust", "repo": "alexanderkjall/sequoia-hongg", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexanderkjall/sequoia-hongg path: /src/main.rs #[macro_use] extern crate honggfuzz; <|fim_suffix|> loop { fuzz!(|data: &[u8]| { if data.len() > 0 { let _ = PacketParser::from_bytes(data); } }); } }<|fim_middle|>use sequoia_openpgp:...
code_fim
medium
{ "lang": "rust", "repo": "alexanderkjall/sequoia-hongg", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GuildOfWeavers/winterfell path: /examples/src/lamport/aggregate/air.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. use super::{ rescue, CYCLE_LENGTH as HA...
code_fim
hard
{ "lang": "rust", "repo": "GuildOfWeavers/winterfell", "path": "/examples/src/lamport/aggregate/air.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> result: &mut [E], current: &[E], next: &[E], ark: &[E], hash_flag: E, sig_cycle_end_flag: E, power_of_two: E, ) { // when hash_flag = 1 (which happens on all steps except steps which are one less than a // multiple of 8 - e.g. all steps except for 7, 15, 23 etc.), and w...
code_fim
hard
{ "lang": "rust", "repo": "GuildOfWeavers/winterfell", "path": "/examples/src/lamport/aggregate/air.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(non_camel_case_types)] #[derive(Debug, Clone, PartialEq, PartialOrd)] pub struct halt { pub halt: u8, } impl halt { pub fn new(halt: u8) -> Message { let header = MessageHeader { message_type: MessageType::command_response, payload_length: 0x01, ...
code_fim
hard
{ "lang": "rust", "repo": "acburigo/rust-bgapi", "path": "/src/system/cmd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: acburigo/rust-bgapi path: /src/system/cmd.rs use bytes::{Buf, BufMut}; use message::{Message, MessageClass, MessageHeader, MessagePayload, MessageType}; use std::io::{Cursor, Read}; #[allow(non_camel_case_types)] #[derive(Debug, Clone, PartialEq, PartialOrd)] pub struct get_bt_address {} impl ...
code_fim
hard
{ "lang": "rust", "repo": "acburigo/rust-bgapi", "path": "/src/system/cmd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //with special formatting println!("{0} - integer, {0:b} - binary, {0:x} - hex, {0:o} - octal, {0:e} - exponential",10); }<|fim_prefix|>// repo: sounakofficial/rust-prac path: /src/formatted_print.rs pub fn formatted_print(){ //general println!("normal string"); //with placeholders ...
code_fim
medium
{ "lang": "rust", "repo": "sounakofficial/rust-prac", "path": "/src/formatted_print.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sounakofficial/rust-prac path: /src/formatted_print.rs pub fn formatted_print(){ //general println!("normal string"); //with placeholders println!("{} is a number, {} is string and {} is boolean,",3.14,"Alice",true); <|fim_suffix|> //with special formatting println!("{0}...
code_fim
hard
{ "lang": "rust", "repo": "sounakofficial/rust-prac", "path": "/src/formatted_print.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>unsafe impl IAdapter for Adapter3 { unsafe fn raw_adp(&self) -> &IDXGIAdapter { &self.ptr } } unsafe impl IAdapter1 for Adapter3 { unsafe fn raw_adp1(&self) -> &IDXGIAdapter1 { &self.ptr } } unsafe impl IAdapter2 for Adapter3 { unsafe fn raw_adp2(&self) -> &IDXGIAdapt...
code_fim
hard
{ "lang": "rust", "repo": "ennis/dxgi-rs", "path": "/src/adapter/adapter3.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { let mut c = 0; let hr = self .raw_adp3() .RegisterHardwareContentProtectionTeardownStatusEvent(event.get_handle(), &mut c); Error::map_if(hr, || HcptStatusCookie(c)) } } fn register_vmbc_event(&self, even...
code_fim
hard
{ "lang": "rust", "repo": "ennis/dxgi-rs", "path": "/src/adapter/adapter3.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ennis/dxgi-rs path: /src/adapter/adapter3.rs use crate::adapter::AdapterType; use crate::adapter::{IAdapter, IAdapter1, IAdapter2}; use com_wrapper::ComWrapper; use dcommon::error::Error; use winapi::shared::dxgi::{IDXGIAdapter, IDXGIAdapter1}; use winapi::shared::dxgi1_2::IDXGIAdapter2; use wi...
code_fim
hard
{ "lang": "rust", "repo": "ennis/dxgi-rs", "path": "/src/adapter/adapter3.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl<Ls, $($param,)* > LensMut<($($param,)*)> for $optic<Ls> where Ls: LensMut<$to>, { fn view_mut<'a>(&self, source: &'a mut ($($param,)*)) -> &'a mut Self::To { self.0.view_mut(&mut source.$field) } ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/lens-rs", "path": "/lens-rs/src/optics.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/lens-rs path: /lens-rs/src/optics.rs ; #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[allow(non_camel_case_types)] pub struct _ref<Optic>(pub Optic); #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[allow(non_camel_case_types)] pub struct _mut<Optic>(pub Optic); #[derive(Copy, Clone, Debug...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/lens-rs", "path": "/lens-rs/src/optics.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/lens-rs path: /lens-rs/src/optics.rs Vec<&'a mut Self::To> { source .as_mut() .err() .into_iter() .flat_map(|t| self.0.traverse_mut(t)) .collect() } } impl<Pm, T, E> PrismRef<Res...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/lens-rs", "path": "/lens-rs/src/optics.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vrkansagara/dotfiles path: /pkg/space/src/window_handle.rs use crate::common::*; pub(crate) struct WindowHandle { pub(crate) id: u64, } impl WindowHandle { pub(crate) fn set_floating(&self, floating: usize) -> Result<(), Error> { let info = self.query()?; if info.floating != float...
code_fim
hard
{ "lang": "rust", "repo": "vrkansagara/dotfiles", "path": "/pkg/space/src/window_handle.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn query(&self) -> Result<WindowInfo, Error> { let child = Command::new("yabai") .arg("-m") .arg("query") .arg("--windows") .arg("--window") .arg(self.id.to_string()) .stdout(Stdio::piped()) .spawn()?; Ok(serde_json::from_reader(child.stdout....
code_fim
hard
{ "lang": "rust", "repo": "vrkansagara/dotfiles", "path": "/pkg/space/src/window_handle.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xenoterracide/brix path: /crates/brix_cli/src/print.rs // Copyright (c) 2021 Ethan Lerner, Caleb Cushing, and the Brix contributors // // This software is released under the MIT License. // https://opensource.org/licenses/MIT <|fim_suffix|>#[macro_export] /// Macro very similar to `eprintln!` i...
code_fim
medium
{ "lang": "rust", "repo": "xenoterracide/brix", "path": "/crates/brix_cli/src/print.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(unused_imports)] use colored::*; #[macro_export] /// Macro very similar to `eprintln!` in the standard library, just prints in red. macro_rules! error { ($start: expr, $($args:tt)*) => {{ eprintln!("{}", format!($start, $($args)*).red()) }}; }<|fim_prefix|>// repo: xenoterracide/b...
code_fim
easy
{ "lang": "rust", "repo": "xenoterracide/brix", "path": "/crates/brix_cli/src/print.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let vector = &mut vec![22]; insertion_sort(vector); assert_eq!(vector, &mut vec![22]); } #[test] fn test_sorting_a_vector_with_length_2() { let vector = &mut vec![22, 11]; insertion_sort(vector); assert_eq!(vector, &mut vec![11, 22]); } ...
code_fim
medium
{ "lang": "rust", "repo": "wtfleming/data-structures-and-algorithms", "path": "/rust/src/insertion_sort.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wtfleming/data-structures-and-algorithms path: /rust/src/insertion_sort.rs pub fn insertion_sort<T>(values: &mut [T]) where T: Ord, { for i in 0..values.len() { for j in (0..i).rev() { if values[j] >= values[j + 1] { values.swap(j, j + 1); ...
code_fim
hard
{ "lang": "rust", "repo": "wtfleming/data-structures-and-algorithms", "path": "/rust/src/insertion_sort.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let vector = &mut vec![55, 22, 11]; insertion_sort(vector); assert_eq!(vector, &mut vec![11, 22, 55]); } #[quickcheck] fn test_sorting_quickcheck(mut xs: Vec<i32>) -> bool { let mut expected = xs.clone(); expected.sort(); insertion_sort(&mut xs...
code_fim
hard
{ "lang": "rust", "repo": "wtfleming/data-structures-and-algorithms", "path": "/rust/src/insertion_sort.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evanjs/diesel_cli_ext path: /test_data/expected_output/schema_mysql.rs #[derive(Queryable, Debug)] pub struct UnitsOfMeasure { pub id: u32, pub volumetricUnitId: Option<u32>, pub weightUnitId: Option<u32>, pub number: Option<f64>, pub createdAt: Option<NaiveDateTime>, pub...
code_fim
hard
{ "lang": "rust", "repo": "evanjs/diesel_cli_ext", "path": "/test_data/expected_output/schema_mysql.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Queryable, Debug)] pub struct UnsignedType { pub id: i32, pub unsignedTinyint: u8, pub nullableUnsignedTinyint: Option<u8>, pub unsignedSmallint: u16, pub nullableUnsignedSmallint: Option<u16>, pub bigint: u64, pub nullableBigint: Option<u64>, } #[derive(Queryable, De...
code_fim
hard
{ "lang": "rust", "repo": "evanjs/diesel_cli_ext", "path": "/test_data/expected_output/schema_mysql.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lightning-project/lightning path: /lightning-core/src/util/drop_guard.rs use std::mem; use std::mem::ManuallyDrop; use std::ops::{Deref, DerefMut}; pub struct DropGuard<T, F: FnOnce(T)> { token: ManuallyDrop<T>, callback: ManuallyDrop<F>, } impl<T, F: FnOnce(T)> DropGuard<T, F> { p...
code_fim
hard
{ "lang": "rust", "repo": "lightning-project/lightning", "path": "/lightning-core/src/util/drop_guard.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> &self.token } } impl<T, F: FnOnce(T)> DerefMut for DropGuard<T, F> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.token } }<|fim_prefix|>// repo: lightning-project/lightning path: /lightning-core/src/util/drop_guard.rs use std::mem; use std::mem::ManuallyDrop; use...
code_fim
medium
{ "lang": "rust", "repo": "lightning-project/lightning", "path": "/lightning-core/src/util/drop_guard.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(guarded_transmute_bool_vec_pedantic(vec![0x00, 0x01, 0x02]), Err(Error { required: 1, actual: 3, reason: ErrorReason::InvalidValue, })); assert_eq!(guarded_transmute_bool_vec_pedantic(vec![0x05, 0x01,...
code_fim
hard
{ "lang": "rust", "repo": "frankier/safe-transmute-rs", "path": "/tests/guarded_transmute_bool_vec_pedantic/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frankier/safe-transmute-rs path: /tests/guarded_transmute_bool_vec_pedantic/mod.rs use safe_transmute::{ErrorReason, Error, guarded_transmute_bool_vec_pedantic}; #[test] fn too_short() { assert_eq!(guarded_transmute_bool_vec_pedantic(vec![]), Err(Error { r...
code_fim
hard
{ "lang": "rust", "repo": "frankier/safe-transmute-rs", "path": "/tests/guarded_transmute_bool_vec_pedantic/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn drop_scope_inside_effect() { let scope = Rc::new(RefCell::new(None)); *scope.borrow_mut() = Some(create_root({ let scope = Rc::clone(&scope); move || { let scope = scope.take(); drop(scope); } }...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/sycamore", "path": "/packages/sycamore/src/rx.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/sycamore path: /packages/sycamore/src/rx.rs //! Reactive primitives for Sycamore. mod context; mod effect; mod iter; mod motion; mod signal; pub use context::*; pub use effect::*; pub use iter::*; pub use motion::*; pub use signal::*; /// Creates a new reactive root / scope. Generally...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/sycamore", "path": "/packages/sycamore/src/rx.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> *scope.borrow_mut() = Some(create_root({ let scope = Rc::clone(&scope); move || { let scope = scope.take(); drop(scope); } })); } }<|fim_prefix|>// repo: isgasho/sycamore path: /packages/sycamore/src/rx.rs //! Reactiv...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/sycamore", "path": "/packages/sycamore/src/rx.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Get<Struct<i32>> for i32 { fn get(&self) -> Struct<i32> { Struct { c: *self } } } fn main() { }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/traits/cycle-trait-type-trait.rs // run-pass #![allow(dead_code)] // Test a case where a supertrait referenc...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/traits/cycle-trait-type-trait.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/traits/cycle-trait-type-trait.rs // run-pass #![allow(dead_code)] // Test a case where a supertrait references a type that references // the original trait. This poses no problem at the moment. // pretty-expanded FIXME #23616 <|fim_suffi...
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/traits/cycle-trait-type-trait.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thepowersgang/rust_os path: /Kernel/tests/network/lwip/src/netconn.rs //! `netconn` - LWIP's "native" network connection interface use ::lwip_sys::*; const TCP_DEFAULT_LISTEN_BACKLOG: u8 = 0xFF; /// A prototype TCP connection (prototype for server/socket structs) pub struct Tcp { conn: *mu...
code_fim
hard
{ "lang": "rust", "repo": "thepowersgang/rust_os", "path": "/Kernel/tests/network/lwip/src/netconn.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/// An open TCP connection (client) pub struct TcpConnection { conn: *mut ::lwip_sys::netconn, } impl TcpConnection { /// Shortcut to connect to a remote host from an unspecified source pub fn connect(ip: ::lwip_sys::ip_addr, port: u16) -> Result<Self,crate::Error> { unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "thepowersgang/rust_os", "path": "/Kernel/tests/network/lwip/src/netconn.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { crate::Error::check_unit(netconn_disconnect(self.conn)).expect("Error deleting a socket connection"); crate::Error::check_unit(netconn_close(self.conn)).expect("Error deleting a socket connection"); crate::Error::check_unit(netconn_delete(self.conn)).ex...
code_fim
hard
{ "lang": "rust", "repo": "thepowersgang/rust_os", "path": "/Kernel/tests/network/lwip/src/netconn.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wasmerio/wasmer path: /lib/wasix/src/syscalls/wasix/sock_listen.rs use super::*; use crate::syscalls::*; /// ### `sock_listen()` /// Listen for connections on a socket /// /// Polling the socket handle will wait until a connection /// attempt is made /// /// Note: This is similar to `listen` //...
code_fim
hard
{ "lang": "rust", "repo": "wasmerio/wasmer", "path": "/lib/wasix/src/syscalls/wasix/sock_listen.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ut ctx: FunctionEnvMut<'_, WasiEnv>, sock: WasiFd, backlog: M::Offset, ) -> Errno { let env = ctx.data(); let net = env.net().clone(); let backlog: usize = wasi_try!(backlog.try_into().map_err(|_| Errno::Inval)); let tasks = ctx.data().tasks().clone(); wasi_try!(__sock_upgrade...
code_fim
hard
{ "lang": "rust", "repo": "wasmerio/wasmer", "path": "/lib/wasix/src/syscalls/wasix/sock_listen.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }