text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /fyrox-core/src/color.rs ge pub fn new(hue: f32, saturation: f32, lightness: f32) -> Self { Self { hue: hue.abs() % 360.0, saturation: saturation.clamp(0.0, 1.0), lightness: lightness.clamp(0.0, 1.0), } } pu...
code_fim
hard
{ "lang": "rust", "repo": "FyroxEngine/Fyrox", "path": "/fyrox-core/src/color.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /fyrox-core/src/color.rs 100.0 - hsv.saturation) * hsv.brightness) / 100.0; let a = (hsv.brightness - vmin) * ((hsv.hue % 60.0) / 60.0); let vinc = vmin + a; let vdec = hsv.brightness - a; Self::from( match hi { ...
code_fim
hard
{ "lang": "rust", "repo": "FyroxEngine/Fyrox", "path": "/fyrox-core/src/color.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Flakebi/webrtc-util path: /src/ifaces/ffi/unix/mod.rs use ::std::io::{Error, ErrorKind}; use std::ffi::CStr; use std::{net, ptr}; use std::net::IpAddr; use crate::ifaces::{Interface, Kind, NextHop}; // https://github.com/Exa-Networks/exaproxy/blob/master/lib/exaproxy/util/interfaces.py pub c...
code_fim
hard
{ "lang": "rust", "repo": "Flakebi/webrtc-util", "path": "/src/ifaces/ffi/unix/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (addr, port) = match unsafe { *sa }.sa_family as i32 { nix::sys::socket::AF_INET => { let sa: *const nix::sys::socket::sockaddr_in = sa as *const nix::libc::sockaddr_in; let sa = &unsafe { *sa }; let (addr, port) = (sa.sin_addr.s_addr, sa.sin_port); ...
code_fim
hard
{ "lang": "rust", "repo": "Flakebi/webrtc-util", "path": "/src/ifaces/ffi/unix/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match vlr { 1 | 3 | 5 | 7 | 9 => println!("Valor impar."), 2 | 4 | 6 | 8 => println!("Valor par."), _ => println!("Valor inválido."), } println!(); print!("Tecle <Enter> para encerrar..."); io::stdout().flush().unwrap(); io::stdin().r...
code_fim
medium
{ "lang": "rust", "repo": "J-AugustoManzano/livro_Rust", "path": "/ExerciciosAprendizagem/Cap03/c03ex11/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: J-AugustoManzano/livro_Rust path: /ExerciciosAprendizagem/Cap03/c03ex11/src/main.rs use std::io; use std::io::prelude::*; fn main() { let mut valor = String::new(); <|fim_suffix|> print!("Entre um valor numérico: "); io::stdout().flush().unwrap(); io::stdin().read_line(&mut...
code_fim
medium
{ "lang": "rust", "repo": "J-AugustoManzano/livro_Rust", "path": "/ExerciciosAprendizagem/Cap03/c03ex11/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dimoret/shadowsocks-rust path: /src/relay/tcprelay/stream.rs // The MIT License (MIT) // Copyright (c) 2015 Y. T. Chung // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Sof...
code_fim
hard
{ "lang": "rust", "repo": "dimoret/shadowsocks-rust", "path": "/src/relay/tcprelay/stream.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_ref(&self) -> &R { &self.reader } /// Gets a mutable reference to the underlying reader. /// /// # Warning /// /// It is inadvisable to read directly from or write directly to the /// underlying reader. pub fn get_mut(&mut self) -> &mut R { &...
code_fim
hard
{ "lang": "rust", "repo": "dimoret/shadowsocks-rust", "path": "/src/relay/tcprelay/stream.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>c = "`read()` method returns [`quadspi_lptr::R`](R) reader structure"] impl crate::Readable for QUADSPI_LPTR_SPEC {} #[doc = "`write(|w| ..)` method takes [`quadspi_lptr::W`](W) writer structure"] impl crate::Writable for QUADSPI_LPTR_SPEC { const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0; const ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp157/quadspi/quadspi_lptr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp157/quadspi/quadspi_lptr.rs #[doc = "Register `QUADSPI_LPTR` reader"] pub type R = crate::R<QUADSPI_LPTR_SPEC>; #[doc = "Register `QUADSPI_LPTR` writer"] pub type W = crate::W<QUADSPI_LPTR_SPEC>; #[doc = "Field `TIMEOUT` reader - TIMEOUT"] p...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp157/quadspi/quadspi_lptr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>:generic::Reg::read) this register and get [`quadspi_lptr::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`quadspi_lptr::W`](W). You can also [`modify`](crate::generic::Reg::modif...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp157/quadspi/quadspi_lptr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ischeinkman/Rust-N-Body path: /src/gravity.rs use particle::*; use math::*; use inv_square::InvSquare; <|fim_suffix|> p.mass } fn tag() -> String { "Gravity".to_owned() } }<|fim_middle|>pub const G : f64 = 6.674e-11; pub struct Gravity {} impl Gravity { pub ...
code_fim
hard
{ "lang": "rust", "repo": "ischeinkman/Rust-N-Body", "path": "/src/gravity.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> G } fn value(p : &Particle) -> f64 { p.mass } fn tag() -> String { "Gravity".to_owned() } }<|fim_prefix|>// repo: ischeinkman/Rust-N-Body path: /src/gravity.rs use particle::*; use math::*; use inv_square::InvSquare; pub const G : f64 = 6.674e-11; <|fim_...
code_fim
hard
{ "lang": "rust", "repo": "ischeinkman/Rust-N-Body", "path": "/src/gravity.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sh1yu/algoritrain-homework path: /src/week1/plus_one.rs // 66. 加一 // 给定一个由 整数 组成的 非空 数组所表示的非负整数,在该数的基础上加一。 // // 最高位数字存放在数组的首位, 数组中每个元素只存储单个数字。 // // 你可以假设除了整数 0 之外,这个整数不会以零开头。 // use super::{Solution}; impl Solution { pub fn plus_one(digits: Vec<i32>) -> Vec<i32> { let mut digits ...
code_fim
medium
{ "lang": "rust", "repo": "sh1yu/algoritrain-homework", "path": "/src/week1/plus_one.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_works() { println!("{:?}", Solution::plus_one(vec![1, 2, 3])); println!("{:?}", Solution::plus_one(vec![0])); println!("{:?}", Solution::plus_one(vec![8, 9, 9])); println!("{:?}", Solution::plus_one(vec![9, 9, 9, 9])); } }<|fim_prefix|>// repo: sh1...
code_fim
medium
{ "lang": "rust", "repo": "sh1yu/algoritrain-homework", "path": "/src/week1/plus_one.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Phantomical/xed path: /src/lib.rs //! #[macro_use] extern crate enum_primitive_derive; <|fim_suffix|>pub use self::init::init_tables; pub type Result<T> = std::result::Result<T, Error>;<|fim_middle|>mod builders; mod enums; mod funcs; mod init; mod structs; mod traits; mod util; pub use self...
code_fim
hard
{ "lang": "rust", "repo": "Phantomical/xed", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::init::init_tables; pub type Result<T> = std::result::Result<T, Error>;<|fim_prefix|>// repo: Phantomical/xed path: /src/lib.rs //! #[macro_use] extern crate enum_primitive_derive; <|fim_middle|>mod builders; mod enums; mod funcs; mod init; mod structs; mod traits; mod util; pub use self...
code_fim
hard
{ "lang": "rust", "repo": "Phantomical/xed", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub type Result<T> = std::result::Result<T, Error>;<|fim_prefix|>// repo: Phantomical/xed path: /src/lib.rs //! #[macro_use] extern crate enum_primitive_derive; mod builders; mod enums; mod funcs; mod init; mod structs; mod traits; mod util; <|fim_middle|>pub use self::builders::*; pub use self::enums...
code_fim
medium
{ "lang": "rust", "repo": "Phantomical/xed", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-lcdif/src/vdctrl0_clr.rs #[doc = "Reader of register VDCTRL0_CLR"] pub type R = crate::R<u32, super::VDCTRL0_CLR>; #[doc = "Writer for register VDCTRL0_CLR"] pub type W = crate::W<u32, super::VDCTRL0_CLR>; #[doc = "Register VDCTRL0_CLR `reset()`'...
code_fim
hard
{ "lang": "rust", "repo": "Shock-1/teensy4-rs", "path": "/imxrt1062-pac/imxrt1062-lcdif/src/vdctrl0_clr.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>efault 0 active low during VSYNC_PULSE_WIDTH time and will be high during the rest of the VSYNC period"] #[inline(always)] pub fn vsync_pol(&self) -> VSYNC_POL_R { VSYNC_POL_R::new(((self.bits >> 27) & 0x01) != 0) } #[doc = "Bit 28 - Setting this bit to 1 will make the hardware gen...
code_fim
hard
{ "lang": "rust", "repo": "Shock-1/teensy4-rs", "path": "/imxrt1062-pac/imxrt1062-lcdif/src/vdctrl0_clr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /src/exchange/coinbase/model/cancel_all_orders.rs use serde::Deserialize; use serde::Serialize; /// Thi<|fim_suffix|>CancelAllOrders { pub product_id: Option<String>, }<|fim_middle|>s struct represents the cancellation of all orders #[derive(Serialize, Deserialize...
code_fim
medium
{ "lang": "rust", "repo": "KaitaoQiu/openlimits", "path": "/src/exchange/coinbase/model/cancel_all_orders.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>CancelAllOrders { pub product_id: Option<String>, }<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /src/exchange/coinbase/model/cancel_all_orders.rs use serde::Deserialize; use serde::Serialize; /// Thi<|fim_middle|>s struct represents the cancellation of all orders #[derive(Serialize, Deserialize...
code_fim
medium
{ "lang": "rust", "repo": "KaitaoQiu/openlimits", "path": "/src/exchange/coinbase/model/cancel_all_orders.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makepad/glui path: /src/cxfonts.rs use std::fs::File; use std::io; use std::io::prelude::*; use std::mem; use crate::cxtextures::*; #[derive(Clone, Default)] pub struct CxFonts{ pub fonts:Vec<Font> } impl CxFonts{ pub fn get(&mut self, id:usize)->&Font{ let font = &mut self.fon...
code_fim
hard
{ "lang": "rust", "repo": "makepad/glui", "path": "/src/cxfonts.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if b.tsingle != 0{ let mut ow = b.toffset; for y in 0..b.th{ for x in 0..b.tw{ let v = s_buf[ow as usize] as u32; tex.image[ (x + ox + ((y + oy) * ff.width))] = (v<<16) | (v<<8) | v; ...
code_fim
hard
{ "lang": "rust", "repo": "makepad/glui", "path": "/src/cxfonts.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mesg = match node.inbox_read.try_recv() { Ok(m) => { m } Err(Empty) => { continue; } Err(Disconnected) => { break;...
code_fim
hard
{ "lang": "rust", "repo": "TyOverby/Thespian", "path": "/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TyOverby/Thespian path: /lib.rs #![crate_id="thespian"] #![feature(default_type_params)] use std::kinds::Send; use std::comm::{ SyncSender, Receiver, Empty, Disconnected }; use std::task::spawn; #[deriving(Send)] pub enum SystemMessage<I> { AddSubscriber(Sender<I>), K...
code_fim
hard
{ "lang": "rust", "repo": "TyOverby/Thespian", "path": "/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ans = node.state.act(mesg); // Try to send messages to all of our listeners, but // Kill everything that can no longer be sent to. node.listeners.retain(|listener| { match listener.send_opt(ans) { ...
code_fim
hard
{ "lang": "rust", "repo": "TyOverby/Thespian", "path": "/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xanahopper/leetcode path: /src/leetcode/editor/cn/solution_498.rs //给你一个大小为 m x n 的矩阵 mat ,请以对角线遍历的顺序,用一个数组返回这个矩阵中的所有元素。 // // // // 示例 1: // // //输入:mat = [[1,2,3],[4,5,6],[7,8,9]] //输出:[1,2,4,7,5,3,6,8,9] // // // 示例 2: // // //输入:mat = [[1,2],[3,4]] //输出:[1,2,3,4] // // // // // 提示: ...
code_fim
hard
{ "lang": "rust", "repo": "xanahopper/leetcode", "path": "/src/leetcode/editor/cn/solution_498.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Solution { pub fn find_diagonal_order(mat: Vec<Vec<i32>>) -> Vec<i32> { let m = mat.len(); let n = mat.first().unwrap().len(); let i_range = 0..m; let j_range = 0..n; let mut res = vec![0; m * n]; let mut index = 0usize; for line in 0..(m + ...
code_fim
hard
{ "lang": "rust", "repo": "xanahopper/leetcode", "path": "/src/leetcode/editor/cn/solution_498.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if val < self.start { self.start } else if val >= self.end { self.end - 1 } else { val } } } impl Solution { pub fn find_diagonal_order(mat: Vec<Vec<i32>>) -> Vec<i32> { let m = mat.len(); let n = mat.first().unwr...
code_fim
hard
{ "lang": "rust", "repo": "xanahopper/leetcode", "path": "/src/leetcode/editor/cn/solution_498.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// functions that don't have a return value actually return the unit type () fn fizzbuzz(n: u32) -> () { if is_divisible_by(n, 15) { println!("fizzbuzz"); } else if is_divisible_by(n, 3) { println!("fizz"); } else if is_divisible_by(n, 5) { println!("buzz"); ...
code_fim
hard
{ "lang": "rust", "repo": "szhongren/rust_learn", "path": "/08_functions/0_functions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: szhongren/rust_learn path: /08_functions/0_functions.rs // fns are declared with fn keyword, and args and return type are type annotated // final expression in a fn is used as a return val, or the return keyword can be used to return from an earlier point // unlike c/c++, there is no restricti...
code_fim
hard
{ "lang": "rust", "repo": "szhongren/rust_learn", "path": "/08_functions/0_functions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use logging::init_default_tracing; pub use logging::init_tracing_with_file; pub use tracing;<|fim_prefix|>// repo: YGBM/datafuse path: /common/tracing/src/lib.rs // Copyright 2020-2021 The Datafuse Authors. // // SPDX-License-Identifier: Apache-2.0. <|fim_middle|>mod logging;
code_fim
easy
{ "lang": "rust", "repo": "YGBM/datafuse", "path": "/common/tracing/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YGBM/datafuse path: /common/tracing/src/lib.rs // Copyright 2020-2021 The Datafuse Authors. // // SPDX-License-Identifier: Apache-2.0. <|fim_suffix|>pub use logging::init_default_tracing; pub use logging::init_tracing_with_file; pub use tracing;<|fim_middle|>mod logging;
code_fim
easy
{ "lang": "rust", "repo": "YGBM/datafuse", "path": "/common/tracing/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mtvu/influxdb_iox path: /influxdb_iox/src/commands/debug/dump_catalog.rs use crate::structopt_blocks::{object_store::ObjectStoreConfig, server_id::ServerIdConfig}; use iox_object_store::IoxObjectStore; use object_store::ObjectStore; use snafu::{OptionExt, ResultExt, Snafu}; use std::{convert::Tr...
code_fim
hard
{ "lang": "rust", "repo": "mtvu/influxdb_iox", "path": "/influxdb_iox/src/commands/debug/dump_catalog.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[snafu(display("Cannot open IOx object store: {}", source))] IoxObjectStoreFailure { source: iox_object_store::IoxObjectStoreError, }, #[snafu(display("Cannot dump catalog: {}", source))] DumpCatalogFailure { source: parquet_catalog::dump::Error, }, } pub type Re...
code_fim
hard
{ "lang": "rust", "repo": "mtvu/influxdb_iox", "path": "/influxdb_iox/src/commands/debug/dump_catalog.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: biuboombiuboom/leetcode path: /rust/src/everyday/e202105/s137.rs use std::collections::HashMap; struct Solution{} impl Solution { pub fn single_number(nums: Vec<i32>) -> i32 { let mut map:HashMap<i32,i32>=HashMap::new(); for elem in nums { if let Some(coun...
code_fim
medium
{ "lang": "rust", "repo": "biuboombiuboom/leetcode", "path": "/rust/src/everyday/e202105/s137.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return single } } pub fn run(){ println!("{}",Solution::single_number(vec! [30000,500,100,30000,100,30000,100])); }<|fim_prefix|>// repo: biuboombiuboom/leetcode path: /rust/src/everyday/e202105/s137.rs use std::collections::HashMap; struct Solution{} impl Solution { pub f...
code_fim
medium
{ "lang": "rust", "repo": "biuboombiuboom/leetcode", "path": "/rust/src/everyday/e202105/s137.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> xs: &BTreeSet<MajorMinor>, path_map: &BTreeMap<&'a DevicePath, MajorMinor>, ) -> BTreeSet<&'a DevicePath> { xs.iter().fold(BTreeSet::new(), |acc, mm| { let paths = path_map .iter() .filter(|(_, pmm)| &mm == pmm) .map(|(p, _)| *p) .collect...
code_fim
hard
{ "lang": "rust", "repo": "beevans/integrated-manager-for-lustre", "path": "/iml-services/iml-device/src/linux_plugin_transforms.rs", "mode": "spm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_prefix|>// repo: beevans/integrated-manager-for-lustre path: /iml-services/iml-device/src/linux_plugin_transforms.rs TreeMap<MajorMinor, LinuxPluginItem<'a>>, pub local_fs: BTreeMap<MajorMinor, (&'a MountPoint, &'a FsType)>, pub mpath: BTreeMap<&'a str, LinuxPluginMpathDevice<'a>>, pub vgs: BTreeMap<...
code_fim
hard
{ "lang": "rust", "repo": "beevans/integrated-manager-for-lustre", "path": "/iml-services/iml-device/src/linux_plugin_transforms.rs", "mode": "psm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GlebShekovtsov/rust_reborn path: /arrays/src/main.rs fn main() { // Массив let a = [1,2,3,4,5]; let months = ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"]; let a1 = [3; 5]; <|fim_suffix|> //Недействите...
code_fim
medium
{ "lang": "rust", "repo": "GlebShekovtsov/rust_reborn", "path": "/arrays/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //Недействительный доступ к элементу массива // let a = [1,2,3,4,5]; // let index = 10; // let element = a[index]; // println!("Значение элемента равно {}", element); }<|fim_prefix|>// repo: GlebShekovtsov/rust_reborn path: /arrays/src/main.rs fn main() { // Массив let a = [1,...
code_fim
medium
{ "lang": "rust", "repo": "GlebShekovtsov/rust_reborn", "path": "/arrays/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> async fn write_all(mut self, data: &[u8]) -> Result<(), io::Error> { (&mut self).write_all(data).await?; self.shutdown().await?; Ok(()) } }<|fim_prefix|>// repo: isgasho/bonsaidb path: /server/src/async_io_util.rs use async_trait::async_trait; use tokio::{ fs, io::...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/bonsaidb", "path": "/server/src/async_io_util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/bonsaidb path: /server/src/async_io_util.rs use async_trait::async_trait; use tokio::{ fs, io::{self, AsyncReadExt, AsyncWriteExt}, }; <|fim_suffix|>#[async_trait] impl FileExt for fs::File { async fn read_all(mut self) -> Result<Vec<u8>, io::Error> { let mut buffer ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/bonsaidb", "path": "/server/src/async_io_util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut known: Vec<u8> = vec![]; 'next: while known.len() != 16 { for possible_byte in 0_u8..=Bounded::max_value() { let mut my_block = vec![0; AES128::BLOCK_SIZE - known.len() - 1]; my_block.push(possible_byte); let padding_len_goal = (known.len() + 1...
code_fim
hard
{ "lang": "rust", "repo": "alvaro-cuesta/rustopals", "path": "/tests/set3/challenge17_padding_oracle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (encrypted, iv) = oracle.get_string(); let blocks = encrypted.chunks(AES128::BLOCK_SIZE).collect::<Vec<_>>(); let mut ivs = vec![iv.as_slice()]; ivs.extend_from_slice(&blocks); let bytes = blocks .iter() .enumerate() .map(|...
code_fim
hard
{ "lang": "rust", "repo": "alvaro-cuesta/rustopals", "path": "/tests/set3/challenge17_padding_oracle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alvaro-cuesta/rustopals path: /tests/set3/challenge17_padding_oracle.rs use rustopals::block::{BlockCipher, AES128}; const STRINGS: &str = include_str!("17.txt"); mod adversary { use rustopals::block::{BlockCipher, BlockMode, AES128, CBC}; use rustopals::util::generate_bytes; pub ...
code_fim
hard
{ "lang": "rust", "repo": "alvaro-cuesta/rustopals", "path": "/tests/set3/challenge17_padding_oracle.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut ret = get_c31_hard_fork_block_height(); if epoch >= 2 { if global::get_chain_type() == global::ChainTypes::Floonet { ret += DAY_HEIGHT; } else { ret += WEEK_HEIGHT; } } let mut i = 3; while i <= epoch { ret += get_epoch_duration(i - 1); i = i + 1; } ret } fn get_epoch_dura...
code_fim
hard
{ "lang": "rust", "repo": "mwcproject/mwc-node", "path": "/core/src/consensus.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mwcproject/mwc-node path: /core/src/consensus.rs timestamp: 1, difficulty, secondary_scaling, is_secondary: true, } } } /// Move value linearly toward a goal pub fn damp(actual: u64, goal: u64, damp_factor: u64) -> u64 { (actual + (damp_factor - 1) * goal) / damp_factor } /// l...
code_fim
hard
{ "lang": "rust", "repo": "mwcproject/mwc-node", "path": "/core/src/consensus.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let genesis_reward: u64 = GENESIS_BLOCK_REWARD; assert_eq!(calc_mwc_block_overage(0, true), genesis_reward); // Doesn't make sense to call for the genesis block assert_eq!(calc_mwc_block_overage(0, false), 0); // Doesn't make sense to call for the genesis block assert_eq!( calc_mwc_block_overa...
code_fim
hard
{ "lang": "rust", "repo": "mwcproject/mwc-node", "path": "/core/src/consensus.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// A procedural macro to declare queues. /// /// This macro should be written as a top-level item in a module, as it expands to statements. For /// each declared queue, it will create a structure and a function named after the given /// identifier, and implementations for the `batch::Queue` and `batch_ra...
code_fim
medium
{ "lang": "rust", "repo": "epitaph-04/batch-rs", "path": "/batch-rabbitmq-codegen/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: epitaph-04/batch-rs path: /batch-rabbitmq-codegen/src/lib.rs //! Procedural macros for the batch_rabbitmq crate. #![recursion_limit = "256"] #![doc(html_root_url = "https://docs.rs/batch-rabbitmq-codegen/0.2.0")] #![deny(missing_debug_implementations)] <|fim_suffix|>mod error; mod queues; ///...
code_fim
medium
{ "lang": "rust", "repo": "epitaph-04/batch-rs", "path": "/batch-rabbitmq-codegen/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: psl8/babys-first-gc path: /src/unsafe_gc.rs use std::ptr::NonNull; const INITIAL_GC_THRESHOLD: usize = 32; #[derive(Clone, Debug)] pub struct GcPtr<T>(NonNull<T>); #[derive(Clone, Debug)] pub struct Object { marked: bool, obj_type: ObjectType, } #[derive(Clone, Debug)] pub enum Objec...
code_fim
hard
{ "lang": "rust", "repo": "psl8/babys-first-gc", "path": "/src/unsafe_gc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.max_objects = num_objects * 2; } fn new_object(&mut self, obj_type: ObjectType) -> GcPtr<Object> { if self.num_objects == self.max_objects { self.gc(); } let mut box_object = Box::new(Object { marked: false, obj_type, ...
code_fim
hard
{ "lang": "rust", "repo": "psl8/babys-first-gc", "path": "/src/unsafe_gc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.num_objects += 1; object } pub fn push_int(&mut self, val: i64) { let obj = self.new_object(ObjectType::Int(val)); self.stack.push(obj); } pub fn push_pair(&mut self) { let tail = Some(self.pop()); let head = Some(self.pop()); ...
code_fim
hard
{ "lang": "rust", "repo": "psl8/babys-first-gc", "path": "/src/unsafe_gc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonthn/newbiecontest path: /programmation/134/rust/src/main.rs #[macro_use] extern crate slog; extern crate slog_async; extern crate slog_term; extern crate reqwest; extern crate cookie; extern crate kuchiki; use kuchiki::traits::*; use slog::Drain; use cookie::{CookieJar, Cookie}; use reqwest:...
code_fim
hard
{ "lang": "rust", "repo": "jonthn/newbiecontest", "path": "/programmation/134/rust/src/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> info!(epreuve, "[+] random number {}", number); let answer = format!("{}?solution={}", url_p2, number); info!(epreuve, "[+] responding 2nd page {}", answer); let reponse_epreuve; match client.get(answer.as_str()).headers(headers_cookie(&authentication, &cookiejar)).send() { ...
code_fim
hard
{ "lang": "rust", "repo": "jonthn/newbiecontest", "path": "/programmation/134/rust/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> info!(authentication, "Logged in newbiecontest.org"); let epreuve = log.new(o!("épreuve" => 134)); info!(epreuve, "[+] accessing 1st page {}", url_p1); let mut res = match client.get(url_p1).headers(headers_cookie(&authentication, &cookiejar)).send() { Ok(o) => o, Err(_)...
code_fim
hard
{ "lang": "rust", "repo": "jonthn/newbiecontest", "path": "/programmation/134/rust/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>e self::style::Style; pub use self::variant::Variant;<|fim_prefix|>// repo: l1h3r/scarab path: /derive/src/internal/mod.rs mod container; mod data; mod field; mod style; mod variant; pub use self::container::Container; pub use <|fim_middle|>self::data::Data; pub use self::field::Field; pub us
code_fim
easy
{ "lang": "rust", "repo": "l1h3r/scarab", "path": "/derive/src/internal/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: l1h3r/scarab path: /derive/src/internal/mod.rs mod container; mod data; mod field; mod style; mod v<|fim_suffix|>self::data::Data; pub use self::field::Field; pub use self::style::Style; pub use self::variant::Variant;<|fim_middle|>ariant; pub use self::container::Container; pub use
code_fim
easy
{ "lang": "rust", "repo": "l1h3r/scarab", "path": "/derive/src/internal/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elbaro/pyplotters path: /src/lib.rs mod backend; mod canvas; mod chart; mod color; mod datetime; mod dtype; mod hack; mod help; mod range; mod series; use help::module as help_pymodule; use backend::Backend; use canvas::Canvas; use chart::Chart; use datetime::{Date, DateTime, Duration, Time}; ...
code_fim
hard
{ "lang": "rust", "repo": "elbaro/pyplotters", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// ezel is a fast Python plotting library. /// Its main focus is a quick visualization for daily data-science and analysis. #[pymodule] fn ezel(_py: Python, m: &PyModule) -> PyResult<()> { // m.add_function(pyo3::wrap_pyfunction!(count, m)?).unwrap(); // m.add_class() // m.add_wrapped(pyo3::...
code_fim
medium
{ "lang": "rust", "repo": "elbaro/pyplotters", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// #[test] // fn it_works() { // pyo3::Python::with_gil(|py| { // let list = pyo3::types::PyList::new(py, &[4, 1, 8, 5, 6, 2, 7, 3]); // let canvas = Py::new(py, crate::Canvas::new(Some(400), Some(300))).unwrap(); // let chart = crate::Chart::new(canvas)...
code_fim
hard
{ "lang": "rust", "repo": "elbaro/pyplotters", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kyeah/aoc path: /2017/rust/src/day_03/part_1.rs pub fn manhattan_distance(val: i32) -> i32 { (1..<i32>::max_value()) .find(|&base| base.pow(2) >= val) .map(|base| penalty(base, val)) .expect("lol") } <|fim_suffix|> for _ in 0..(base.pow(2) - val) { decr = ...
code_fim
hard
{ "lang": "rust", "repo": "kyeah/aoc", "path": "/2017/rust/src/day_03/part_1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // begin at the end of the corner and decrement. let mut decr = true; let mut penalty = max; for _ in 0..(base.pow(2) - val) { decr = (!decr && penalty == max) || (decr && penalty != min); penalty += if decr { -1 } else { 1 }; } penalty }<|fim_prefix|>// repo: kye...
code_fim
hard
{ "lang": "rust", "repo": "kyeah/aoc", "path": "/2017/rust/src/day_03/part_1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-datetime/zoneinfo-data path: /src/data/Asia/Kamchatka.rs // ------ // This file is autogenerated! // Any changes you make may be overwritten. // ------ use std::borrow::Cow; use datetime::zone::{StaticTimeZone, FixedTimespanSet, FixedTimespan}; pub static ZONE: StaticTimeZone<'static> =...
code_fim
hard
{ "lang": "rust", "repo": "rust-datetime/zoneinfo-data", "path": "/src/data/Asia/Kamchatka.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>offset 43200, DST offset 3600 is_dst: true, name: Cow::Borrowed("PETST"), }), (1067090400, FixedTimespan { // 2003-10-25T14:00:00.000 UTC offset: 43200, // UTC offset 43200, DST offset 0 is_dst: false, name: Cow::Borrowed("P...
code_fim
hard
{ "lang": "rust", "repo": "rust-datetime/zoneinfo-data", "path": "/src/data/Asia/Kamchatka.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if a > &2000. { b } else { a } }<|fim_prefix|>// repo: skial/back-to-basics path: /rustlang/functions/params/src/main.rs fn main() { println!("Hello, world!"); let a = 34564.; let b = 12399.994; println!("two_arity result is {}", two_arity(a, b)); println!(...
code_fim
easy
{ "lang": "rust", "repo": "skial/back-to-basics", "path": "/rustlang/functions/params/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: skial/back-to-basics path: /rustlang/functions/params/src/main.rs fn main() { println!("Hello, world!"); let a = 34564.; let b = 12399.994; println!("two_arity result is {}", two_arity(a, b)); println!("two_arity_ref result is {}", two_arity_ref(&a, &b)); } <|fim_suffix|> ...
code_fim
easy
{ "lang": "rust", "repo": "skial/back-to-basics", "path": "/rustlang/functions/params/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 2color/prisma-engines path: /libs/datamodel/core/tests/renderer/literals.rs use datamodel::DefaultValue; use indoc::indoc; use pretty_assertions::assert_eq; use prisma_value::PrismaValue; #[test] fn strings_with_quotes_render_as_escaped_literals() { let input = indoc!( r#" m...
code_fim
hard
{ "lang": "rust", "repo": "2color/prisma-engines", "path": "/libs/datamodel/core/tests/renderer/literals.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let input = indoc!( r#" model Category { id String @id name String @default("xyz\\Datasource\\Model") } "# ); let dml = datamodel::parse_datamodel(input).unwrap().subject; let rendered = datamodel::render_datamodel_to_string(&dml); ...
code_fim
hard
{ "lang": "rust", "repo": "2color/prisma-engines", "path": "/libs/datamodel/core/tests/renderer/literals.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn internal_escaped_values_are_rendered_correctly() { let dm = indoc!( r#" model FilmQuote { id Int @id }"# ); let expected_dm = indoc!( r#" model FilmQuote { id Int @id @default("xyz\\Datasource\\Model") ...
code_fim
hard
{ "lang": "rust", "repo": "2color/prisma-engines", "path": "/libs/datamodel/core/tests/renderer/literals.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FelixMo42/buster path: /src/generator/gen_tus.rs use crate::ast; use crate::scope; fn add(tab: &str) -> String { return format!(" {}", tab) } fn str_map<'a, T>(arr: &Vec<T>, func: impl Fn(&T) -> String) -> Vec<String> { return arr.iter().map(func).collect::<Vec<String>>(); } fn encode_stat...
code_fim
hard
{ "lang": "rust", "repo": "FelixMo42/buster", "path": "/src/generator/gen_tus.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn encode_kind<'a>(kind: &'a scope::Kind , _tab: &str) -> String { return format!("{}", kind.base); } fn encode<'a>(node: &'a ast::Node<'a> , tab: &str) -> String { match node { ast::Node::FuncMake (a) => format!("([{}]\n{})", str_map( & a.params, |arg| format!("{} {}", encode_kind(&arg.ki...
code_fim
medium
{ "lang": "rust", "repo": "FelixMo42/buster", "path": "/src/generator/gen_tus.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let tmp = last; last = last + second_last; second_last = tmp; i = i + 1; } println!("The {n}th fibonacci is {last}"); }<|fim_prefix|>// repo: roblass/learning path: /rust/chapter_3/fibonacci/src/main.rs fn main() { let n = std::env::args().nth(1).exp...
code_fim
medium
{ "lang": "rust", "repo": "roblass/learning", "path": "/rust/chapter_3/fibonacci/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: roblass/learning path: /rust/chapter_3/fibonacci/src/main.rs fn main() { let n = std::env::args().nth(1).expect("no pattern given"); let n = n.parse::<i32>().unwrap(); let mut last = 1; let mut second_last = 0; <|fim_suffix|> let tmp = last; last = last + second...
code_fim
easy
{ "lang": "rust", "repo": "roblass/learning", "path": "/rust/chapter_3/fibonacci/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("The {n}th fibonacci is {last}"); }<|fim_prefix|>// repo: roblass/learning path: /rust/chapter_3/fibonacci/src/main.rs fn main() { let n = std::env::args().nth(1).expect("no pattern given"); let n = n.parse::<i32>().unwrap(); let mut last = 1; let mut second_last = 0; ...
code_fim
easy
{ "lang": "rust", "repo": "roblass/learning", "path": "/rust/chapter_3/fibonacci/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clap-rs/clap_generate path: /src/shells/fish.rs // Std use std::io::Write; // Internal use clap::App; pub struct FishGen<'a, 'b>(&'b App<'a, 'b>) where 'a: 'b; impl<'a, 'b> FishGen<'a, 'b> { pub fn new(app: &'b App<'a, 'b>) -> Self { FishGen(app) } pub fn generate_to<W: Write>(&s...
code_fim
hard
{ "lang": "rust", "repo": "clap-rs/clap_generate", "path": "/src/shells/fish.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut basic_template = format!("complete -c {} -n ", root_command); if root_command == subcommand { basic_template.push_str("\"__fish_use_subcommand\""); } else { basic_template.push_str(format!("\"__fish_seen_subcommand_from {}\"", subcommand).as_str()); } for optio...
code_fim
hard
{ "lang": "rust", "repo": "clap-rs/clap_generate", "path": "/src/shells/fish.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } impl R { #[doc = "Bits 0:31 - Host Transmit descriptor Address Pointer Cleared on Reset."] #[inline(always)] pub fn htd(&self) -> HTD_R { HTD_R::new((self.bits & 0xffff_ffff) as u32) } } #[doc = "Channelx Current Host Transmit descriptor\n\nThis register you...
code_fim
hard
{ "lang": "rust", "repo": "lpc-rs/lpc-pac", "path": "/lpc54608/src/enet/dma_ch/dma_chx_cur_hst_txdesc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> R(reader) } } #[doc = "Field `HTD` reader - Host Transmit descriptor Address Pointer Cleared on Reset."] pub struct HTD_R(crate::FieldReader<u32, u32>); impl HTD_R { pub(crate) fn new(bits: u32) -> Self { HTD_R(crate::FieldReader::new(bits)) } } impl core::ops::Deref for HTD_R ...
code_fim
medium
{ "lang": "rust", "repo": "lpc-rs/lpc-pac", "path": "/lpc54608/src/enet/dma_ch/dma_chx_cur_hst_txdesc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lpc-rs/lpc-pac path: /lpc54608/src/enet/dma_ch/dma_chx_cur_hst_txdesc.rs #[doc = "Register `DMA_CHx_CUR_HST_TXDESC` reader"] pub struct R(crate::R<DMA_CHX_CUR_HST_TXDESC_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DMA_CHX_CUR_HST_TXDESC_SPEC>; #[inline(always)] fn de...
code_fim
hard
{ "lang": "rust", "repo": "lpc-rs/lpc-pac", "path": "/lpc54608/src/enet/dma_ch/dma_chx_cur_hst_txdesc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yaanhyy/future_prj path: /src/tcp_test.rs use tokio::net::TcpStream; use tokio::prelude::*; use std::net::ToSocketAddrs; use tokio::io::{read_to_end, write_all}; use std::fs::File; use std::net::SocketAddr; const REQ_BODY: &[u8] = b"GET /json HTTP/1.1\r\nHost: httpbin.org\r\nConnection: close\r...
code_fim
hard
{ "lang": "rust", "repo": "yaanhyy/future_prj", "path": "/src/tcp_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn tcp_spawn_cli() { tokio::run(future::poll_fn(|| { let mut args = std::env::args().skip(4); loop { match (args.next(), args.next(), args.next()) { (Some(host), Some(path), Some(filename)) => { tokio::spawn(download(host, path, filename)...
code_fim
hard
{ "lang": "rust", "repo": "yaanhyy/future_prj", "path": "/src/tcp_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let future = TcpStream::connect(&addr) .and_then(|stream| { write_all(stream, REQ_BODY) }).and_then(|(stream, _body)| { let buffer = vec![]; read_to_end(stream, buffer) }).map(|(_stream, buffer)| { let s = std::str::from_utf8(&buffer).unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "yaanhyy/future_prj", "path": "/src/tcp_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TanNgocDo/hbbft path: /src/sender_queue/queueing_honey_badger.rs //! Convenience methods for a `SenderQueue` wrapping a `QueueingHoneyBadger`. use std::result; use crypto::PublicKey; use rand::Rand; use serde::{de::DeserializeOwned, Serialize}; use super::{SenderQueue, SenderQueueableDistAlgo...
code_fim
hard
{ "lang": "rust", "repo": "TanNgocDo/hbbft", "path": "/src/sender_queue/queueing_honey_badger.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Casts a vote to add a node as a validator. /// /// This stores a pending vote for the change. It will be included in some future batch, and /// once enough validators have been voted for the same change, it will take effect. pub fn vote_to_add(&mut self, node_id: N, pub_key: Public...
code_fim
hard
{ "lang": "rust", "repo": "TanNgocDo/hbbft", "path": "/src/sender_queue/queueing_honey_badger.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>413012, 1048.09241244180), (0.00000001076, 2.97284479790, 2957.48933064529), (0.00000001230, 2.33341924042, 1354.67697632690), (0.00000001240, 5.94758800259, 610.93615626891), ...
code_fim
hard
{ "lang": "rust", "repo": "nxnfufunezn/vsop87-rs", "path": "/src/vsop87c/jupiter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nxnfufunezn/vsop87-rs path: /src/vsop87c/jupiter.rs 00, 1.57257401507, 634.51202950500), (0.00000000486, 5.04467319390, 2203.94120481581), (0.00000000515, 6.13663617559, 1091.11831706170), ...
code_fim
hard
{ "lang": "rust", "repo": "nxnfufunezn/vsop87-rs", "path": "/src/vsop87c/jupiter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub const Z3: [(f64, f64, f64); 39] = [(0.00001302949, 3.38307505290, 529.69096509460), (0.00000638849, 2.73076320051, 522.57741809380), (0.00000252188, 1.03735897029, 536.80451209540), (0....
code_fim
hard
{ "lang": "rust", "repo": "nxnfufunezn/vsop87-rs", "path": "/src/vsop87c/jupiter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> where S: serde::Serializer, { if let ValueOwned::Void = self { let mut st = serializer.serialize_struct("S", 1)?; st.serialize_field("type", "Void")?; return st.end(); } let mut st = serializer.serialize_struct("S", 2)?; m...
code_fim
hard
{ "lang": "rust", "repo": "sekmet/flow.rs", "path": "/cadence_json/src/ser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sekmet/flow.rs path: /cadence_json/src/ser.rs use serde::ser::SerializeStruct; use serde::Serialize; use crate::wrapper::*; use crate::{ValueOwned, ValueRef}; impl<'a> AsRef<ValueRef<'a>> for ValueRef<'a> { #[inline] fn as_ref(&self) -> &ValueRef<'a> { self } } impl<'a> Se...
code_fim
hard
{ "lang": "rust", "repo": "sekmet/flow.rs", "path": "/cadence_json/src/ser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lightdiscord/Shushus path: /crates/shushus-oauth2/src/states.rs use std::sync::{ Arc, Mutex }; use uuid::Uuid; pub struct States(Arc<Mutex<Vec<Uuid>>>); impl States { pub fn create(&self) -> Uuid { let uuid = Uuid::new_v4(); self.0.lock().unwrap().push(uuid); uuid...
code_fim
hard
{ "lang": "rust", "repo": "lightdiscord/Shushus", "path": "/crates/shushus-oauth2/src/states.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn apply(&self, uuid: &Uuid) -> Option<Uuid> { let mut lock = self.0.lock().unwrap(); let index = lock.iter().position(|x| x == uuid)?; Some(lock.remove(index)) } } impl Default for States { fn default() -> Self { States(Arc::new(Mutex::new(Vec::new()))) ...
code_fim
medium
{ "lang": "rust", "repo": "lightdiscord/Shushus", "path": "/crates/shushus-oauth2/src/states.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for States { fn default() -> Self { States(Arc::new(Mutex::new(Vec::new()))) } }<|fim_prefix|>// repo: lightdiscord/Shushus path: /crates/shushus-oauth2/src/states.rs use std::sync::{ Arc, Mutex }; use uuid::Uuid; pub struct States(Arc<Mutex<Vec<Uuid>>>); impl States { ...
code_fim
hard
{ "lang": "rust", "repo": "lightdiscord/Shushus", "path": "/crates/shushus-oauth2/src/states.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn resolve_commands(&mut self, windows: &mut Windows, graphics: &mut Graphics, app_commands: &mut Receiver<AppCommand>, event_loop_target: &EventLoopWindowTarget<()>) { let cmds: Vec<AppCommand> = app_commands.tr...
code_fim
hard
{ "lang": "rust", "repo": "andreasterrius/alers", "path": "/crates/ale_app/src/app.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andreasterrius/alers path: /crates/ale_app/src/app.rs use std::collections::HashMap; use log::info; use ale_data::channel::{Channel, Receiver, Sender}; use ale_math::color::Color; use ale_math::rect::Rect; use ale_math::{Vector2, Zero}; use ale_opengl::{ ale_opengl_blend_enable, ale_opengl_c...
code_fim
hard
{ "lang": "rust", "repo": "andreasterrius/alers", "path": "/crates/ale_app/src/app.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: snaztoz/neondb path: /storage/src/alloc/rssalloc.rs use super::*; use crate::ops::Ops; use rssblock::RSSBlock; use std::convert::TryInto; const NULL_ADDRESS: u64 = 0; mod init; mod rssblock; /// Really-Simple Storage Allocator. /// /// Mengimplementasikan alokasi storage dengan menggunakan s...
code_fim
hard
{ "lang": "rust", "repo": "snaztoz/neondb", "path": "/storage/src/alloc/rssalloc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> debug_assert!(address != NEONDB_FILE_ALLOCATABLE_START); if !self.is_initialized { return Err(ErrorKind::AllocatorNotInitialized); } let real_address = address - RSSBlock::META_SIZE; let i = self .find_used_block_index(real_address) ...
code_fim
hard
{ "lang": "rust", "repo": "snaztoz/neondb", "path": "/storage/src/alloc/rssalloc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let abstract_address = address + RSSBlock::META_SIZE; Ok(abstract_address) } fn dealloc(&mut self, vol: &mut File, address: u64) -> Result<()> { debug_assert!(address != NEONDB_FILE_ALLOCATABLE_START); if !self.is_initialized { return Err(ErrorKind::Al...
code_fim
hard
{ "lang": "rust", "repo": "snaztoz/neondb", "path": "/storage/src/alloc/rssalloc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }