text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> // move { println!("Test-3: move"); let s1 = String::from("hello"); println!("addr of s1 is {:p}", s1.as_ptr()); let s2 = s1; //// s1 now is invalid println!("addr of s2 is {:p}", s2.as_ptr()); // two ptrs point to "hello" in heap } ...
code_fim
hard
{ "lang": "rust", "repo": "septicmk/experiment", "path": "/rust/exp-4/clone-move.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: septicmk/experiment path: /rust/exp-4/clone-move.rs fn main(){ { //s is agnostic let val = 5; //the scope of val } // val is invalid // val is free automatically // basic type is clone { println!("Test-1: basic type"); let x = 5; ...
code_fim
hard
{ "lang": "rust", "repo": "septicmk/experiment", "path": "/rust/exp-4/clone-move.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let completion = cqe.user_data() as *mut Mutex<State>; if completion != ptr::null_mut() { let mut state = (*completion).lock(); match mem::replace(&mut *state, State::Completed(cqe.raw_result())) { State::Submitted(waker) => waker.wake(), State::Can...
code_fim
hard
{ "lang": "rust", "repo": "nexoscp/ringbahn", "path": "/src/completion.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nexoscp/ringbahn path: /src/completion.rs use std::io; use std::mem; use std::ptr::{self, NonNull}; use std::task::Waker; use parking_lot::Mutex; use crate::event::Cancellation; pub struct Completion { state: NonNull<Mutex<State>>, } unsafe impl Send for Completion { } unsafe impl Sync f...
code_fim
hard
{ "lang": "rust", "repo": "nexoscp/ringbahn", "path": "/src/completion.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) unsafe fn cancel(self, mut callback: Cancellation) { let mut state = self.state.as_ref().lock(); if matches!(&*state, State::Completed(_)) { drop(state); callback.cancel(); self.deallocate(); } else { *state = State::Ca...
code_fim
hard
{ "lang": "rust", "repo": "nexoscp/ringbahn", "path": "/src/completion.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rosds/binn path: /binn/src/lib.rs use std::{ convert::{TryFrom, TryInto}, ffi::{c_void, CStr}, os::raw::{c_char, c_int}, }; use binn_sys::binn_ptr; #[non_exhaustive] #[derive(Debug)] pub enum BinnValue<'a> { Int8(i8), Int16(i16), Int32(i32), Int64(i64), UInt8(u8...
code_fim
hard
{ "lang": "rust", "repo": "rosds/binn", "path": "/binn/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let _binn = BinnObject::new(); } #[test] fn setters_getters_test() { let mut binn = BinnObject::new(); let k = |s: &str| -> CString { CString::new(s).unwrap() }; let hello = CStr::from_bytes_with_nul(b"hello\0").unwrap(); binn.set(&k("i8"), 42i8); ...
code_fim
hard
{ "lang": "rust", "repo": "rosds/binn", "path": "/binn/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> binn.set(&k("i8"), 42i8); binn.set(&k("i16"), 42i16); binn.set(&k("i32"), 42i32); binn.set(&k("i64"), 42i64); binn.set(&k("u8"), 42u8); binn.set(&k("u16"), 42u16); binn.set(&k("u32"), 42u32); binn.set(&k("u64"), 42u64); binn.set(&k("f...
code_fim
hard
{ "lang": "rust", "repo": "rosds/binn", "path": "/binn/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kamyau/tari-university path: /src/cryptography/digital_signatures/src/pubkey.rs extern crate libsecp256k1_rs; use libsecp256k1_rs::{ SecretKey, PublicKey }; <|fim_suffix|> // Create the secret key "1" let k = SecretKey::from_hex("000000000000000000000000000000000000000000000000000000000...
code_fim
medium
{ "lang": "rust", "repo": "kamyau/tari-university", "path": "/src/cryptography/digital_signatures/src/pubkey.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Create the secret key "1" let k = SecretKey::from_hex("0000000000000000000000000000000000000000000000000000000000000001").unwrap(); // Generate the public key, P = k.G let pub_from_k = PublicKey::from_secret_key(&k); let known_pub = PublicKey::from_hex("0479BE667EF9DCBBAC55A06295CE8...
code_fim
medium
{ "lang": "rust", "repo": "kamyau/tari-university", "path": "/src/cryptography/digital_signatures/src/pubkey.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuancaimaiyi/leogate path: /ros2-sys/src/ros2/ffi.rs /* automatically generated by rust-bindgen 0.56.0 */ pub const true_: u32 = 1; pub const false_: u32 = 0; pub const __bool_true_false_are_defined: u32 = 1; pub type wchar_t = ::std::os::raw::c_int; #[repr(C)] #[repr(align(16))] #[derive(Copy,...
code_fim
hard
{ "lang": "rust", "repo": "yuancaimaiyi/leogate", "path": "/ros2-sys/src/ros2/ffi.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( ::std::mem::size_of::<_json_payload>(), 16usize, concat!("Size of: ", stringify!(_json_payload)) ); assert_eq!( ::std::mem::align_of::<_json_payload>(), 8usize, concat!("Alignment of ", stringify!(_json_payload)) ); assert_eq!( unsafe { &(*(::std::ptr::nul...
code_fim
hard
{ "lang": "rust", "repo": "yuancaimaiyi/leogate", "path": "/ros2-sys/src/ros2/ffi.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // --- begin --- // let mut grid = [[char; 10]; 20]; let mut empty_idx = usize::MAX; let mut consec_lines = 0; // populate grid from top to bottom for y in 0..20 { let mut hash_count = 0; let mut empty_cell_idx = usize::MAX; for x in 0..10 { let cell = v[...
code_fim
hard
{ "lang": "rust", "repo": "bhubr/rust-samples", "path": "/bdev-2106-ex3/bdev-2106-ex3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bhubr/rust-samples path: /bdev-2106-ex3/bdev-2106-ex3.rs use std::env; use std::fs; use std::collections::HashMap; fn main() { let filename = "samples/input3.txt"; let contents = fs::read_to_string(filename).expect("Something went wrong reading the file"); let mut v: Vec<String> =...
code_fim
hard
{ "lang": "rust", "repo": "bhubr/rust-samples", "path": "/bdev-2106-ex3/bdev-2106-ex3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut empty_idx = usize::MAX; let mut consec_lines = 0; // populate grid from top to bottom for y in 0..20 { let mut hash_count = 0; let mut empty_cell_idx = usize::MAX; for x in 0..10 { let cell = v[19 - y].chars().nth(x).unwrap(); // println!("x, y: {}...
code_fim
hard
{ "lang": "rust", "repo": "bhubr/rust-samples", "path": "/bdev-2106-ex3/bdev-2106-ex3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(parts[0], "!markov"); assert!(parts.len() > 1); match parts[1] { "emulate" => { if parts.len() < 3 { if let Err(e) = self .server .send_privmsg(channel, "Usage: !markov emula...
code_fim
hard
{ "lang": "rust", "repo": "alekratz/markov-bot-rs", "path": "/src/bot.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alekratz/markov-bot-rs path: /src/bot.rs use cbor; use irc::client::prelude::*; use markov_chain::Chain; use rand::{self, Rng}; use std::collections::HashMap; use std::fs::OpenOptions; use std::io::{self, Read, Write}; type UserSettingsMap = HashMap<String, HashMap<String, UserSettings>>; type ...
code_fim
hard
{ "lang": "rust", "repo": "alekratz/markov-bot-rs", "path": "/src/bot.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> // Reply if we feel like it let random = rand::thread_rng().next_f64(); if random < chance { let generated = { self.user_chain_mut(channel, sender).generate_sentence() }; let message = format!("{}: {}", sender, generated); ...
code_fim
hard
{ "lang": "rust", "repo": "alekratz/markov-bot-rs", "path": "/src/bot.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sashalemon/spark-coupling path: /transport-libs/native/src/ring.rs //! Contains the shared memory transport for libcourier use memmap::{Mmap, Protection, MmapView}; use std::io::Write; use std::ffi::CString; use libc::{sem_open,sem_close,sem_wait,sem_post,sem_t, O_RDWR, O_CREAT, S_IRWXU}; /// `...
code_fim
hard
{ "lang": "rust", "repo": "sashalemon/spark-coupling", "path": "/transport-libs/native/src/ring.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl ::std::ops::Drop for Ring { fn drop(&mut self) { unsafe { //sem_unlink(...); make the other side do this, and ensure they always open second? //sem_unlink(...; or save the names sem_close(self.empty); sem_close(self.full); sem_cl...
code_fim
hard
{ "lang": "rust", "repo": "sashalemon/spark-coupling", "path": "/transport-libs/native/src/ring.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hugobenichi/calc path: /calc.rs use std::env; #[derive(Debug, Clone, Copy)] enum Atom { Void, Num(i64), Plus, Minus, Mul, Div, Mod, Pow, } fn parse(atom: &str) -> Atom { match atom { "+" => return Atom::Plus, "-" => return Atom::Minus, "*" => return Atom::Mul, ...
code_fim
hard
{ "lang": "rust", "repo": "hugobenichi/calc", "path": "/calc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match a { Atom::Void => {}, Atom::Num(x) => s.push(x), Atom::Plus => apply_binary_op(s, |x, y| x + y), Atom::Minus => apply_binary_op(s, |x, y| x - y), Atom::Mul => apply_binary_op(s, |x, y| x * y), Atom::Div => apply_binary_op(s, |x, y| x / y), Atom::Mod ...
code_fim
medium
{ "lang": "rust", "repo": "hugobenichi/calc", "path": "/calc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut stack = Vec::new(); for arg in env::args() { for p in arg.split_whitespace() { reduce(&mut stack, parse(&p)); } } println!("stack = {:?}", stack); }<|fim_prefix|>// repo: hugobenichi/calc path: /calc.rs use std::env; #[derive(Debug, Clone, Copy)] enum Atom { ...
code_fim
hard
{ "lang": "rust", "repo": "hugobenichi/calc", "path": "/calc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mcy/zpet path: /src/lib.rs extern crate tempfile; extern crate regex; extern crate rand; #[macro_use] extern crate lazy_static; <|fim_suffix|>pub use zephyr::Notice; pub use zephyr::Direction; pub use zephyr::Triplet;<|fim_middle|>pub mod bot; pub mod command; pub mod zephyr; pub use bot::Bot...
code_fim
medium
{ "lang": "rust", "repo": "mcy/zpet", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use bot::Bot; pub use command::Command; pub use command::Handler; pub use command::Scope; pub use command::Shape; pub use zephyr::Notice; pub use zephyr::Direction; pub use zephyr::Triplet;<|fim_prefix|>// repo: mcy/zpet path: /src/lib.rs extern crate tempfile; extern crate regex; extern crate rand;...
code_fim
easy
{ "lang": "rust", "repo": "mcy/zpet", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 2BitSalute/grpc-rs path: /grpc-sys/src/lib.rs // Copyright 2017 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obta<|fim_suffix|>se is distributed on an "AS IS" BASIS, // See the L...
code_fim
medium
{ "lang": "rust", "repo": "2BitSalute/grpc-rs", "path": "/grpc-sys/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>(non_snake_case)] #![allow(non_upper_case_globals)] #[allow(clippy::all)] mod bindings { include!(env!("BINDING_PATH")); } mod grpc_wrap; pub use bindings::*; pub use grpc_wrap::*;<|fim_prefix|>// repo: 2BitSalute/grpc-rs path: /grpc-sys/src/lib.rs // Copyright 2017 PingCAP, Inc. // // Licensed unde...
code_fim
hard
{ "lang": "rust", "repo": "2BitSalute/grpc-rs", "path": "/grpc-sys/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>se is distributed on an "AS IS" BASIS, // See the License for the specific language governing permissions and // limitations under the License. #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #[allow(clippy::all)] mod bindings { include!(env!("BINDING_PATH"...
code_fim
medium
{ "lang": "rust", "repo": "2BitSalute/grpc-rs", "path": "/grpc-sys/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>//pub use _p::*; //pub use _p_upper::*; pub use _QStartNoAckMode::*; pub use _QThreadEvents::*; pub use _QuestionMark::*; //pub use _c::*; pub use _d_upper::*; pub use _g::*; pub use _g_upper::*; pub use _h_upper::*; //pub use _k::*; pub use _m::*; pub use _m_upper::*; pub use _qAttached::*; pub use _qC::...
code_fim
hard
{ "lang": "rust", "repo": "jasonwhite/reverie", "path": "/reverie-ptrace/src/gdbstub/commands/base/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jasonwhite/reverie path: /reverie-ptrace/src/gdbstub/commands/base/mod.rs /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ <...
code_fim
hard
{ "lang": "rust", "repo": "jasonwhite/reverie", "path": "/reverie-ptrace/src/gdbstub/commands/base/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn embedded_type(&self) -> EmbeddedType { self.embedded_type } fn value(&self) -> f64 { self.value.unwrap_or(0.) } } #[derive(juniper::GraphQLEnum, Clone, Copy, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] pub enum EmbeddedType { One, Another, } #[derive(...
code_fim
hard
{ "lang": "rust", "repo": "briandeboer/mongodb-service-template", "path": "/src/models/embedded.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(juniper::GraphQLEnum, Clone, Copy, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] pub enum EmbeddedType { One, Another, } #[derive(Serialize, Deserialize, juniper::GraphQLInputObject)] pub struct NewEmbedded { #[serde(rename = "_id")] pub id: Option<ID>, pub embedded_ty...
code_fim
medium
{ "lang": "rust", "repo": "briandeboer/mongodb-service-template", "path": "/src/models/embedded.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: briandeboer/mongodb-service-template path: /src/models/embedded.rs use bson::doc; use chrono::{DateTime, Utc}; use mongodb_base_service::{Node, NodeDetails, ID}; use serde::{Deserialize, Serialize}; use std::hash::Hash; use crate::schema::Context; #[derive(Clone, Debug, Serialize, Deserialize)...
code_fim
medium
{ "lang": "rust", "repo": "briandeboer/mongodb-service-template", "path": "/src/models/embedded.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0x192/iced_aw path: /src/style/tab_bar.rs //! Displays a [`TabBar`](crate::native::tab_bar::TabBar) to select the content //! to be displayed. //! //! You have to manage the logic to show the contend by yourself or you may want //! to use the [`Tabs`](crate::native::tabs::Tabs) widget instead. /...
code_fim
hard
{ "lang": "rust", "repo": "0x192/iced_aw", "path": "/src/style/tab_bar.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// The icon color of the tab labels. pub icon_color: Color, /// The text color of the tab labels. pub text_color: Color, } /// The appearance of a [`TabBar`](crate::native::tab_bar::TabBar). pub trait StyleSheet { /// The normal appearance0of a tab bar and its tab labels. /// ...
code_fim
hard
{ "lang": "rust", "repo": "0x192/iced_aw", "path": "/src/style/tab_bar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: will14smith/RustyPhotography path: /photography-api/src/edit_photograph.rs use std::{ collections::HashMap, sync::Arc }; use rocket_contrib::json::Json; use rocket::{ State, http::Status }; use serde::Deserialize; use crate::models::PhotographDto; #[derive(Deserialize)] #[serde(rename_all = "Pa...
code_fim
hard
{ "lang": "rust", "repo": "will14smith/RustyPhotography", "path": "/photography-api/src/edit_photograph.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> updates } } #[put("/photograph/<id>", format = "json", data = "<input>")] pub fn edit_photograph(client: State<Arc<photography_data::Client>>, id: String, input: Json<EditPhotographDto>) -> Result<Json<PhotographDto>, Status> { let id = uuid::Uuid::parse_str(&id).map_err(|_| Status::BadRe...
code_fim
hard
{ "lang": "rust", "repo": "will14smith/RustyPhotography", "path": "/photography-api/src/edit_photograph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let photograph = client.update_photograph(id, updates).map_err(|e| { eprintln!("Failed to update photograph: {:?}", e); Status::InternalServerError })?; Ok(Json((&photograph).into())) }<|fim_prefix|>// repo: will14smith/RustyPhotography path: /photography-api/src/edit_photog...
code_fim
hard
{ "lang": "rust", "repo": "will14smith/RustyPhotography", "path": "/photography-api/src/edit_photograph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match (l1, l2) { (Some(l1), Some(l2)) => { if l1.val < l2.val { v.push(l1.val); return Solution::mtl(l1.next, Some(l2), v); } else { v.push(l2.val); return Solution::mtl(l2.n...
code_fim
hard
{ "lang": "rust", "repo": "pearzl/leetcode_rust", "path": "/src/answer/q0021_merge_two_sorted_lists.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pearzl/leetcode_rust path: /src/answer/q0021_merge_two_sorted_lists.rs // q0021_merge_two_sorted_lists struct Solution; use crate::util::ListNode; impl Solution { pub fn merge_two_lists( l1: Option<Box<ListNode>>, l2: Option<Box<ListNode>>, ) -> Option<Box<ListNode>> {...
code_fim
hard
{ "lang": "rust", "repo": "pearzl/leetcode_rust", "path": "/src/answer/q0021_merge_two_sorted_lists.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ($($l,)*) = self; let ($($r,)*) = rhs; ($($l,)* $($r,)*) } } #[allow(non_camel_case_types)] impl<$($l,)* $($r),*> OpSplit<$L<$($l),*>> for $O<$($l,)* $($r),*> { type R = $R<$...
code_fim
hard
{ "lang": "rust", "repo": "toddmath/advent-of-code-2020", "path": "/common/src/tuple.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: toddmath/advent-of-code-2020 path: /common/src/tuple.rs Mut(Self::Element) -> T; } pub trait Splat<T> { fn splat(value: T) -> Self; } pub trait Call<T> { type Output; fn call(&self, args: T) -> Self::Output; } pub trait CallOnce<T> { type Output; fn call_once(self, args: T...
code_fim
hard
{ "lang": "rust", "repo": "toddmath/advent-of-code-2020", "path": "/common/src/tuple.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: toddmath/advent-of-code-2020 path: /common/src/tuple.rs } T12 A12 { A.a.0, B.b.1, C.c.2, D.d.3, E.e.4, F.f.5, G.g.6, H.h.7, I.i.8, J.j.9, K.k.10, L.l.11 } T13 A13 { A.a.0, B.b.1, C.c.2, D.d.3, E.e.4, F.f.5, G.g.6, H.h.7, I.i.8, J.j.9, K.k.10, L.l.11, M.m.12 } T14 A14 { A.a.0, B.b.1, C.c.2, D.d.3...
code_fim
hard
{ "lang": "rust", "repo": "toddmath/advent-of-code-2020", "path": "/common/src/tuple.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krzyz/quantum-plots path: /quantum-tools/src/state.rs extern crate nalgebra; extern crate num; use crate::basis::Basis; use crate::braket::Braket; use crate::context::Context; use crate::system::System; use nalgebra::{convert, ComplexField, DMatrix, DVector, RowDVector}; use num::complex::Compl...
code_fim
hard
{ "lang": "rust", "repo": "krzyz/quantum-plots", "path": "/quantum-tools/src/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match context.value { Ket(ref vec) => { State::problem_ket(&system.eigensystem.eigenvectors * vec, Some(system)) } Bra(ref vec) => State::problem_bra( vec * &system.eigensystem.eigen...
code_fim
hard
{ "lang": "rust", "repo": "krzyz/quantum-plots", "path": "/quantum-tools/src/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[rstest] fn evolve_solution_psi_valid_success(solution_psi_2: State<'static>, system2: System) { let psi = solution_psi_2.with_system(&system2); let res_ket = psi.evolve(0.1).unwrap(); let correct_ket = State::solution_ket_from_slice( &vec![ Co...
code_fim
hard
{ "lang": "rust", "repo": "krzyz/quantum-plots", "path": "/quantum-tools/src/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atticlab/spl-megapool_1 path: /token-mega-swap/program/src/error.rs //! Error types use num_derive::FromPrimitive; use num_traits::FromPrimitive; use solana_program::{ decode_error::DecodeError, msg, program_error::PrintProgramError, program_error::ProgramError, }; use thiserror::Error; //...
code_fim
hard
{ "lang": "rust", "repo": "atticlab/spl-megapool_1", "path": "/token-mega-swap/program/src/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[error("Overflow")] Overflow, #[error("Operation must be on two pool tokens")] OperationMustBeOnTwoPoolTokens, #[error("Operation must be on two pool tokens")] TokenProviderAndSwapMustBeSigners, } impl From<PoolError> for ProgramError { fn from(e: PoolError) -> Self { ...
code_fim
medium
{ "lang": "rust", "repo": "atticlab/spl-megapool_1", "path": "/token-mega-swap/program/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn get_props(&self) -> MyValueObjectProps { MyValueObjectProps { value: self.props.value } } fn equals(&self, other: impl ValueObject<MyValueObjectProps>) -> bool { self.props == other.get_props() } } fn main() {}<|fim_prefix|>// repo: arconia-software...
code_fim
hard
{ "lang": "rust", "repo": "arconia-software/ddd-toolkit-rust", "path": "/examples/value_object.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arconia-software/ddd-toolkit-rust path: /examples/value_object.rs use ddd_toolkit::building_blocks::domain::value_object::ValueObject; use crate::building_blocks::domain::value_object::DomainValueObject; <|fim_suffix|> MyValueObject { props } } fn get_props(&self) -> MyValueObje...
code_fim
hard
{ "lang": "rust", "repo": "arconia-software/ddd-toolkit-rust", "path": "/examples/value_object.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sim82/squirrel-rs path: /src/object.rs use super::{bytecode, types, Object}; use std::collections::HashMap; #[derive(Debug)] pub struct Closure { pub func_proto: Object, } impl Closure { pub fn new(func_proto: Object) -> Self { Closure { func_proto: func_proto, ...
code_fim
hard
{ "lang": "rust", "repo": "sim82/squirrel-rs", "path": "/src/object.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for f in &self.functions { if let Object::FuncProto(func) = f { func.print_disassembly(&format!("{} ", indent)[..]); } } } } #[derive(Debug, Clone)] pub struct Table { pub map: HashMap<Object, Object>, } impl Table { pub fn new() -> Se...
code_fim
hard
{ "lang": "rust", "repo": "sim82/squirrel-rs", "path": "/src/object.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { let myobj:Vec<&str>=item.split("=>").collect(); return Ok(myobj[1].trim_matches('"').to_string()); } } Ok("127.0.0.1:1196".to_string()) }<|fim_prefix|>// repo: plscar/r_server path: /src/common/config.rs use std::{ fs::File, io, io::prelude::* }; ...
code_fim
medium
{ "lang": "rust", "repo": "plscar/r_server", "path": "/src/common/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plscar/r_server path: /src/common/config.rs use std::{ fs::File, io, io::prelude::* }; ///获取config.cnf中的特定键所对应的值 pub fn get_config(key:&str)->Result<String,io::Error> { let mykey="\"".to_string()+key+&"\"".to_<|fim_suffix|> { let myobj:Vec<&str>=item.split("=>").c...
code_fim
hard
{ "lang": "rust", "repo": "plscar/r_server", "path": "/src/common/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> block_on(async { for _ in 0..num_tasks { rx.next().await.unwrap(); } let lock = mutex.lock().await; assert_eq!(num_tasks, *lock); }); } std::thread::sleep(std::time::Duration::from_millis(500)); // wait for background ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/futures-rs", "path": "/futures/tests/lock_mutex.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/futures-rs path: /futures/tests/lock_mutex.rs use futures::channel::mpsc; use futures::executor::{block_on, ThreadPool}; use futures::future::{ready, FutureExt}; use futures::lock::Mutex; use futures::stream::StreamExt; use futures::task::{Context, SpawnExt}; use futures_test::future::...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/futures-rs", "path": "/futures/tests/lock_mutex.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(counter, 1); assert!(waiter.poll_unpin(&mut panic_context()).is_ready()); } #[test] fn mutex_contested() { { let (tx, mut rx) = mpsc::unbounded(); let pool = ThreadPool::builder().pool_size(16).create().unwrap(); let tx = Arc::new(tx); let mutex = A...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/futures-rs", "path": "/futures/tests/lock_mutex.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quebin31/oxicoin path: /src/utils.rs use std::cmp::Ordering; use hmac::{Hmac, Mac}; use ripemd160::Ripemd160; use sha2::{Digest, Sha256}; use crate::{Error, Result}; pub(crate) fn prepend_padding<A, T>(vec: A, size: usize, with: T) -> Result<Vec<T>> where T: Clone, A: Into<Vec<T>>, { ...
code_fim
hard
{ "lang": "rust", "repo": "quebin31/oxicoin", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} impl Chain for Hmac<Sha256> { fn chain(mut self, data: &[u8]) -> Self { self.update(data); self } } pub(crate) fn default<T: Default>() -> T { Default::default() }<|fim_prefix|>// repo: quebin31/oxicoin path: /src/utils.rs use std::cmp::Ordering; use hmac::{Hmac, Mac}; us...
code_fim
hard
{ "lang": "rust", "repo": "quebin31/oxicoin", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/functions-closures/closure-inference.rs // run-pass fn foo(i: isize) -> isize { i + 1 } <|fim_suffix|> pub fn main() { let f = {|i| foo(i)}; assert_eq!(apply(f, 2), 3); }<|fim_middle|> fn apply<A, F>(f: F, v: A) -> A where F: FnOnce(A)...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/functions-closures/closure-inference.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn main() { let f = {|i| foo(i)}; assert_eq!(apply(f, 2), 3); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/functions-closures/closure-inference.rs // run-pass fn foo(i: isize) -> isize { i + 1 } <|fim_middle|> fn apply<A, F>(f: F, v: A) -> A where F: FnOnce(A) ...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/functions-closures/closure-inference.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Ok(result) = engine.eval::<i64>("9 >> 1") { assert_eq!(result, 4); } else { assert!(false); } }<|fim_prefix|>// repo: Radviger/rhai path: /tests/bit_shift.rs extern crate rhai; use rhai::Engine; #[test] fn test_left_shift() { <|fim_middle|> let mut engine = Engine:...
code_fim
hard
{ "lang": "rust", "repo": "Radviger/rhai", "path": "/tests/bit_shift.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Radviger/rhai path: /tests/bit_shift.rs extern crate rhai; use rhai::Engine; #[test] fn test_left_shift() { let mut engine = Engine::new(); <|fim_suffix|> let mut engine = Engine::new(); if let Ok(result) = engine.eval::<i64>("9 >> 1") { assert_eq!(result, 4); } else {...
code_fim
medium
{ "lang": "rust", "repo": "Radviger/rhai", "path": "/tests/bit_shift.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cambricorp/terminal_cli.rs path: /cli_core/src/cli.rs use prelude::v1::*; use property::*; use terminal::*; use autocomplete::*; use cli_property::*; use cli_command::*; use super::i18n::Strings; pub trait CliContext<'a> { /// Creates a new prefixed execution context, but only if the current l...
code_fim
hard
{ "lang": "rust", "repo": "cambricorp/terminal_cli.rs", "path": "/cli_core/src/cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(args) = args { let ctx = CommandContext { args: args.into(), terminal: self.terminal, current_path: "" }; return Some(ctx); } } None } fn property<'b, V, P, Id: Into<Cow<'b, str>>>(&'b mut self, property_id: Id, input_parser: P) -> Option<Propert...
code_fim
hard
{ "lang": "rust", "repo": "cambricorp/terminal_cli.rs", "path": "/cli_core/src/cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: happydpc/harmony path: /src/graphics/pipelines/specular2.rs use legion::prelude::Resources; use crate::{ graphics::{ pipeline_manager::{PipelineDesc, PipelineManager}, resources::{GPUResourceManager, ProbeUniform}, }, AssetManager, }; pub fn create(resources: &Resou...
code_fim
hard
{ "lang": "rust", "repo": "happydpc/harmony", "path": "/src/graphics/pipelines/specular2.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> skybox_desc.layouts = vec!["specular_globals".to_string()]; skybox_desc.cull_mode = wgpu::CullMode::None; skybox_desc .vertex_state .set_index_format(wgpu::IndexFormat::Uint16); let specular_globals_buffer = device.create_buffer_with_data( bytemuck::bytes_of(&Probe...
code_fim
hard
{ "lang": "rust", "repo": "happydpc/harmony", "path": "/src/graphics/pipelines/specular2.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> let mut list = vec![]; let f = move || { for _ in 0..10000 { list.push("item 123"); } }; let t1 = thread::spawn(f); //let t2 = thread::spawn(f); // compile error! t1.join().unwrap(); //t2.join().unwrap(); } //Usually, &str will be used for functi...
code_fim
medium
{ "lang": "rust", "repo": "theodesp/learning-rust", "path": "/src/forth.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //return string; // compile error! return String::from("hello"); } use std::thread; fn threads() { let mut list = vec![]; let f = move || { for _ in 0..10000 { list.push("item 123"); } }; let t1 = thread::spawn(f); //let t2 = thread::spawn(f); //...
code_fim
medium
{ "lang": "rust", "repo": "theodesp/learning-rust", "path": "/src/forth.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theodesp/learning-rust path: /src/forth.rs struct User { name: String, } fn main() { let name = String::from("User"); let user1 = User { name }; //let user2 = User { name }; // compile error } fn get_string() -> String { let string = String::from("hello"); drop(string...
code_fim
hard
{ "lang": "rust", "repo": "theodesp/learning-rust", "path": "/src/forth.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut configs = Vec::new(); loop { count += 1; let nbytes = &sourceFile.read(&mut buffer).unwrap(); // 如果找到了资源 // if let Some(size) = find_subsequence(&buffer, &*defaultResourceHead.getHead()) { if let Some(size) = memmem::Finder::new(&*defaultResourceHe...
code_fim
hard
{ "lang": "rust", "repo": "834772509/Appender", "path": "/src/core.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 打开目标文件 let mut sourceFile = File::open(targetFilePath)?; // 缓冲区 let mut buffer = [0u8; BUFFER_SIZE]; let mut count = 0; let mut configs = Vec::new(); loop { count += 1; let nbytes = &sourceFile.read(&mut buffer).unwrap(); // 如果找到了资源 // if ...
code_fim
hard
{ "lang": "rust", "repo": "834772509/Appender", "path": "/src/core.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 834772509/Appender path: /src/core.rs use std::path::Path; use std::error::Error; use std::fs::{OpenOptions, File}; use std::io::{Write, Read, SeekFrom, Seek}; use std::convert::TryFrom; use std::fs; use std::cmp::Ordering; use serde::{Serialize, Deserialize}; use memchr::memmem; use crate::util...
code_fim
hard
{ "lang": "rust", "repo": "834772509/Appender", "path": "/src/core.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/core/tests/parquet/page_pruning.rs !(batch.num_rows(), 651); let session_ctx = SessionContext::new(); let task_ctx = session_ctx.task_ctx(); // 5.create filter date_string_col == 1; let filter = col("date_string_col").eq(lit("01/01/0...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/core/tests/parquet/page_pruning.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/core/tests/parquet/page_pruning.rs k_ctx = session_ctx.task_ctx(); // create filter month == 1 and year = 2009; let filter = col("month").eq(lit(1_i32)).and(col("year").eq(lit(2009))); let parquet_exec = get_parquet_exec(&state, filter)....
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/core/tests/parquet/page_pruning.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let parquet_exec = get_parquet_exec(&state, filter).await; let mut results = parquet_exec.execute(0, task_ctx.clone()).unwrap(); let batch = results.next().await.unwrap().unwrap(); // should same with `month = 1` assert_eq!(batch.num_rows(), 651); let session_ctx = SessionConte...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/core/tests/parquet/page_pruning.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RonSheely/logicsim path: /src/data_structures/immutable.rs use std::ops::Deref; /// Data structure that enforces immutability at compile time. /// /// It implements [Deref] so all operations on the underlying type will /// work as normal, as long as they take an immutable reference. /// /// # E...
code_fim
medium
{ "lang": "rust", "repo": "RonSheely/logicsim", "path": "/src/data_structures/immutable.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self(i) } } impl<T> Deref for Immutable<T> { type Target = T; fn deref(&self) -> &Self::Target { self.get_immutable() } } #[cfg(test)] mod tests { use super::*; // TODO add failing test if this goes anywhere. // https://github.com/rust-lang/rust/issues/12335....
code_fim
medium
{ "lang": "rust", "repo": "RonSheely/logicsim", "path": "/src/data_structures/immutable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Deref for Immutable<T> { type Target = T; fn deref(&self) -> &Self::Target { self.get_immutable() } } #[cfg(test)] mod tests { use super::*; // TODO add failing test if this goes anywhere. // https://github.com/rust-lang/rust/issues/12335. #[test] fn test_...
code_fim
medium
{ "lang": "rust", "repo": "RonSheely/logicsim", "path": "/src/data_structures/immutable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where D: DeserializeOwned, { let actor = self .tree .get_actor(addr) .ok_or_else(|| Error::State("Could not retrieve actor from state tree".to_owned()))?; let act: D = self.bs.get(&actor.state)?.ok_or_else(|| { Error::State("C...
code_fim
hard
{ "lang": "rust", "repo": "bxlkm1/forest", "path": "/blockchain/state_manager/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bxlkm1/forest path: /blockchain/state_manager/src/lib.rs // Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT mod errors; pub use self::errors::*; use actor::{MinerInfo, StorageMinerActorState}; use address::Address; use blockstore::BlockStore; use encoding::de::Dese...
code_fim
medium
{ "lang": "rust", "repo": "bxlkm1/forest", "path": "/blockchain/state_manager/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>NG=fDTS/2, N=6"] FDTS_DIV2_N6, #[doc = "fSAMPLING=fDTS/2, N=8"] FDTS_DIV2_N8, #[doc = "fSAMPLING=fDTS/4, N=6"] FDTS_DIV4_N6, #[doc = "fSAMPLING=fDTS/4, N=8"] FDTS_DIV4_N8, #[doc = "fSAMPLING=fDTS/8, N=6"] FDTS_DIV8_N6, #[doc = "fSAMPLING=fDTS/8, N=8"] FDTS_DIV8_...
code_fim
hard
{ "lang": "rust", "repo": "burrbull/stm32f1-gates", "path": "/src/stm32f100/tim2/ccmr1_input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.variant(CC2SW::TI1) } #[doc = "CC2 channel is configured as input, IC2 is mapped on TRC"] #[inline] pub fn trc(self) -> &'a mut W { self.variant(CC2SW::TRC) } #[doc = r" Writes raw bits to the field"] #[inline] pub fn bits(self, value: u8) -> &'a mut W { ...
code_fim
hard
{ "lang": "rust", "repo": "burrbull/stm32f1-gates", "path": "/src/stm32f100/tim2/ccmr1_input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: burrbull/stm32f1-gates path: /src/stm32f100/tim2/ccmr1_input.rs K_INT_N4`"] #[inline] pub fn is_fck_int_n4(&self) -> bool { *self == IC1FR::FCK_INT_N4 } #[doc = "Checks if the value of the field is `FCK_INT_N8`"] #[inline] pub fn is_fck_int_n8(&self) -> bool { ...
code_fim
hard
{ "lang": "rust", "repo": "burrbull/stm32f1-gates", "path": "/src/stm32f100/tim2/ccmr1_input.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { Edition::E2015 => write!(f, "2015"), Edition::E2018 => write!(f, "2018"), Edition::E2021 => write!(f, "2021"), } } }<|fim_prefix|>// repo: sigmaSd/IRust path: /crates/irust_repl/src/edition.rs #[cfg(feature = "serde")] use serde::{Deser...
code_fim
hard
{ "lang": "rust", "repo": "sigmaSd/IRust", "path": "/crates/irust_repl/src/edition.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sigmaSd/IRust path: /crates/irust_repl/src/edition.rs #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use std::str::FromStr; #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, Copy, Default)] pub enum Edition { E2015, E2018, #[defaul...
code_fim
hard
{ "lang": "rust", "repo": "sigmaSd/IRust", "path": "/crates/irust_repl/src/edition.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Command for CreateSessionCommand { type ResponseType = CreateSessionResponse; } /// Response from `command::create_session` #[derive(Serialize, Deserialize, Debug)] pub(crate) struct CreateSessionResponse { /// Randomly generated challenge from the card pub card_challenge: Challenge, ...
code_fim
medium
{ "lang": "rust", "repo": "drahnr/yubihsm-rs", "path": "/src/session/command/create.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drahnr/yubihsm-rs path: /src/session/command/create.rs //! Create a new encrypted session with the YubiHSM2 using the given connector //! //! <https://developers.yubico.com/YubiHSM2/Commands/Create_Session.html> use command::{Command, CommandCode}; use object::ObjectId; use response::Response; ...
code_fim
medium
{ "lang": "rust", "repo": "drahnr/yubihsm-rs", "path": "/src/session/command/create.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut sum = 0.0f64; let nterms = 200; for k in 0..nterms { sum += negbinom.pmf(nterms - k - 1); } print!("Sum of first {} PMF values: ", nterms); out(sum, true); }<|fim_prefix|>// repo: WarrenWeckesser/experiments path: /rust/statrs_demos/src/bin/negative_binomial_demo.r...
code_fim
hard
{ "lang": "rust", "repo": "WarrenWeckesser/experiments", "path": "/rust/statrs_demos/src/bin/negative_binomial_demo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WarrenWeckesser/experiments path: /rust/statrs_demos/src/bin/negative_binomial_demo.rs // Example of the `NegativeBinomial` distribution. use statrs::distribution::{Discrete, DiscreteCDF, NegativeBinomial}; <|fim_suffix|> let mut sum = 0.0f64; let nterms = 200; for k in 0..nterms { ...
code_fim
hard
{ "lang": "rust", "repo": "WarrenWeckesser/experiments", "path": "/rust/statrs_demos/src/bin/negative_binomial_demo.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ip_version_4 = IpKind::V4(String::from("127.0.0.1")); let ip_version_6 = IpKind::V6(String::from("..1")); println!("{:#?}",ip_version_4); println!("{:#?}",ip_version_6); }<|fim_prefix|>// repo: AreebSiddiqui/ONSITE-PIAIC- path: /chapter6_1/p3/src/main.rs #[derive(Debug)] enum IpKind {...
code_fim
easy
{ "lang": "rust", "repo": "AreebSiddiqui/ONSITE-PIAIC-", "path": "/chapter6_1/p3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AreebSiddiqui/ONSITE-PIAIC- path: /chapter6_1/p3/src/main.rs #[derive(Debug)] enum IpKind { V4 (String), V6 (String), } <|fim_suffix|> let ip_version_4 = IpKind::V4(String::from("127.0.0.1")); let ip_version_6 = IpKind::V6(String::from("..1")); println!("{:#?}",ip_version_4);...
code_fim
easy
{ "lang": "rust", "repo": "AreebSiddiqui/ONSITE-PIAIC-", "path": "/chapter6_1/p3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.refraction_index } fn get_visible_color(&self, normal: &Vector, view: &Vector, light_direction: &Vector, light_color: &Color) -> Color { // Note - view & light have opposite directions here let half = (light_direction - ...
code_fim
medium
{ "lang": "rust", "repo": "hippopotamus-prime/rust-raytracer", "path": "/src/blinn_phong.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hippopotamus-prime/rust-raytracer path: /src/blinn_phong.rs use crate::color::Color; use crate::render::Surface; use crate::vector_math; use crate::vector_math::Vector; pub struct BlinnPhong { pub color: Color, pub diffuse_component: f32, pub specular_component: f32, pub shine: ...
code_fim
medium
{ "lang": "rust", "repo": "hippopotamus-prime/rust-raytracer", "path": "/src/blinn_phong.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut diffuse_contrib = 0.0; let ndl = vector_math::dot(normal, light_direction); if ndl > 0.0 { diffuse_contrib = self.diffuse_component * ndl; } Color { r: light_color.r * (specular_contrib + diffuse_contrib * self.color....
code_fim
hard
{ "lang": "rust", "repo": "hippopotamus-prime/rust-raytracer", "path": "/src/blinn_phong.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Gets or inserts the given card into the store. pub async fn get_or_insert(&self, card: RawCard) -> Result<Card> { let mut tx = self.pool.begin().await?; // Attempt to get this card by name let card_name = card.name.as_str(); if let Some(card) = sqlx::query_as!(...
code_fim
hard
{ "lang": "rust", "repo": "dcchut/robbot", "path": "/src/models/cards/local.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dcchut/robbot path: /src/models/cards/local.rs use crate::models::cards::{Card, RawCard}; use anyhow::{Context, Result}; use sqlx::{Pool, Sqlite}; pub(super) struct LocalCardStorage<'pool> { pool: &'pool Pool<Sqlite>, } impl<'pool> LocalCardStorage<'pool> { pub fn new(pool: &'pool Pool...
code_fim
hard
{ "lang": "rust", "repo": "dcchut/robbot", "path": "/src/models/cards/local.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marsmxm/snippets path: /tutorials/rust/variables/src/main.rs fn main() { let mut x = 5; println!("The value of x is: {}", x); x = 6; println!("The value of x is: {}", x); let x = 5; let x = x + 1; let x = x * 2; println!("The value of x is: {}", x); <|fim_suffix...
code_fim
medium
{ "lang": "rust", "repo": "marsmxm/snippets", "path": "/tutorials/rust/variables/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s1 = String::from("hello"); let s2 = s1; println!("{}, world!", s2); let s1 = String::from("hello"); let s2 = s1.clone(); println!("s1 = {}, s2 = {}", s1, s2); }<|fim_prefix|>// repo: marsmxm/snippets path: /tutorials/rust/variables/src/main.rs fn main() { let mut x = 5; ...
code_fim
hard
{ "lang": "rust", "repo": "marsmxm/snippets", "path": "/tutorials/rust/variables/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s1 = String::from("hello"); let s2 = s1.clone(); println!("s1 = {}, s2 = {}", s1, s2); }<|fim_prefix|>// repo: marsmxm/snippets path: /tutorials/rust/variables/src/main.rs fn main() { let mut x = 5; println!("The value of x is: {}", x); x = 6; println!("The value of x is: ...
code_fim
hard
{ "lang": "rust", "repo": "marsmxm/snippets", "path": "/tutorials/rust/variables/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }