text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> /// Remove an item on the shard's local thread.
pub(super) fn remove_local(&self, addr: Address) {
let page_idx = addr.page();
if let Some(page) = self.shared.get(page_idx) {
page.remove_local(self.local(page_idx), addr);
}
}
/// Remove an item, while ... | code_fim | hard | {
"lang": "rust",
"repo": "oshunter/fuchsia",
"path": "/third_party/rust_crates/vendor/tokio/src/util/slab/shard.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize)]
struct Animal {
name: String,
legs: u8,
}
#[async_std::main]
async fn main() -> tide::Result<()> {
let contents = get_config("~/data/british-english").await?;
let mut app = tide::new();
app.at("/orders/shoes").post(order_shoes);
app.listen("127.0.0.1... | code_fim | medium | {
"lang": "rust",
"repo": "suren-m/rsw",
"path": "/async-app/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: suren-m/rsw path: /async-app/src/main.rs
use async_std::fs;
use std::io::Error;
use tide::prelude::*;
use tide::Request;
const CONFIG_FILE: &str = "config.txt";
<|fim_suffix|>async fn order_shoes(mut req: Request<()>) -> tide::Result {
let Animal { name, legs } = req.body_json().await?;
... | code_fim | hard | {
"lang": "rust",
"repo": "suren-m/rsw",
"path": "/async-app/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> nums.iter()
.zip(&nums[1..])
.map(|(previous, current)| current - previous)
.max()
.unwrap()
} else {
0
}
}
}
// ------------------------------------------------------ snip ------------------------... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0164_maximum_gap/radix_sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for count in &mut counts {
*count = 0;
}
mem::swap(&mut nums, &mut temp);
offset += mask_bits;
if offset >= num_bits {
break;
}
}
nums
}
pub fn maximum_gap(nums: Vec<i32>) -... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0164_maximum_gap/radix_sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0164_maximum_gap/radix_sort.rs
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::mem;
impl Solution {
fn radix_sort(mut nums: Vec<i32>, max: i32) -> Vec<... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0164_maximum_gap/radix_sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>lf) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12);
self.w
}
}
#[doc = "Reader of field `GPIO4... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/gpio/int1set.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trembel/ambiq-apollo3p-pac path: /src/gpio/int1set.rs
he field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bi... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/gpio/int1set.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 14)) | (((value as u32) & 0x01) << 14);
self.w
}
}
#[doc = "Reader of field `GPIO45`"]
pub type GPIO45_R = crate::R<bool, bool>;
#[doc = "Wr... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/gpio/int1set.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vuenc/Advent-of-Code-2018 path: /src/day4.rs
// use std::cmp::{max};
use regex::Regex;
use self::GuardAction::*;
use bit_vec::BitVec;
use std::collections::HashMap;
#[derive(Debug, PartialEq, Eq)]
enum GuardAction {
BeginsShift,
WakesUp,
FallsAsleep
}
#[derive(Debug)]
struct GuardE... | code_fim | hard | {
"lang": "rust",
"repo": "Vuenc/Advent-of-Code-2018",
"path": "/src/day4.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut guard_map = HashMap::new();
for day in days {
guard_map.entry(day.guard_id)
.or_insert(vec![])
.push(day);
}
let mut max_guard_asleep_per_minute = vec![(0, None); 60];
for &guard_id in guard_map.keys() {
let mut guard_asleep_by_minute = ... | code_fim | hard | {
"lang": "rust",
"repo": "Vuenc/Advent-of-Code-2018",
"path": "/src/day4.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tyan-boot/tap-demo path: /src/app.rs
use std::env;
use std::fs::File;
use std::io::Read;
use std::net::{IpAddr, UdpSocket};
use std::sync::{Arc, RwLock};
use std::time::Duration;
use clap::ArgMatches;
use log::error;
use crate::control::control_thread;
use crate::discovery::{discovery_thread, ... | code_fim | hard | {
"lang": "rust",
"repo": "tyan-boot/tap-demo",
"path": "/src/app.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> peer.unwrap()
})
.collect();
Ok(peers)
}
pub(crate) fn run(args: &ArgMatches) -> AppResult<()> {
let tap_info = create_tap()?;
let data_sock = create_data_sock()?;
let is_auto = args.is_present("auto");
// init peers from args
let init_peers = match a... | code_fim | hard | {
"lang": "rust",
"repo": "tyan-boot/tap-demo",
"path": "/src/app.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn set_led(n: u8, r: &mut impl OutputPin, g: &mut impl OutputPin, b: &mut impl OutputPin) {
match n {
1 => {
r.set_high().ok();
g.set_low().ok();
b.set_low().ok();
}
2 => {
r.set_high().ok();
g.set_high().ok();
... | code_fim | hard | {
"lang": "rust",
"repo": "FreeMasen/mtx_btn",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use std::collections::HashMap;
use std::collections::HashSet;
impl Solution {
pub fn relative_sort_array(arr1: Vec<i32>, arr2: Vec<i32>) -> Vec<i32> {
let set: HashSet<i32> = arr2.iter().copied().collect();
let mut histogram: HashMap<i32, usize> = HashMap::new();
let mut tail:... | code_fim | medium | {
"lang": "rust",
"repo": "potatosalad/leetcode",
"path": "/src/n1122_relative_sort_array.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gyng/rcue path: /src/parser.rs
}
}
Ok(Command::Isrc(isrc)) => {
if last_track(&mut cue).is_some() {
last_track(&mut cue).unwrap().isrc = Some(isrc);
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "gyng/rcue",
"path": "/src/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_bad_intentation() {
let cue = parse_from_file("test/fixtures/bad_indentation.cue", true).unwrap();
assert_eq!(cue.title, Some("Loveless".to_string()));
assert_eq!(cue.files.len(), 1);
assert_eq!(cue.files[0].tracks.len(), 2);
assert_eq!(
... | code_fim | hard | {
"lang": "rust",
"repo": "gyng/rcue",
"path": "/src/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gyng/rcue path: /src/parser.rs
last_track(&mut cue).unwrap().flags = flags;
} else {
fail_if_strict!(i, l, "FLAG assigned to no TRACK");
}
}
Ok(Command::Isrc(isrc)) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "gyng/rcue",
"path": "/src/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ys)]
pub fn difsel(&self) -> DIFSEL_R {
DIFSEL_R::new((self.bits & 0x000f_ffff) as u32)
}
}
impl W {
#[doc = "Bits 0:19 - ADC channel differential or single-ended mode for channel"]
#[inline(always)]
pub fn difsel(&mut self) -> DIFSEL_W {
DIFSEL_W { w: self }
}
}<|f... | code_fim | hard | {
"lang": "rust",
"repo": "Yatekii/stm32mp1-pac",
"path": "/src/adc1/adc_difsel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yatekii/stm32mp1-pac path: /src/adc1/adc_difsel.rs
#[doc = "Reader of register ADC_DIFSEL"]
pub type R = crate::R<u32, super::ADC_DIFSEL>;
#[doc = "Writer for register ADC_DIFSEL"]
pub type W = crate::W<u32, super::ADC_DIFSEL>;
#[doc = "Register ADC_DIFSEL `reset()`'s with value 0"]
impl crate::... | code_fim | hard | {
"lang": "rust",
"repo": "Yatekii/stm32mp1-pac",
"path": "/src/adc1/adc_difsel.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ncatelli/mud path: /mud/src/web/event.rs
extern crate serde;
extern crate serde_json;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum EventType {
Game,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Event {
event: EventType,
message: String,
}
<|fim_suffix|> pub ... | code_fim | hard | {
"lang": "rust",
"repo": "ncatelli/mud",
"path": "/mud/src/web/event.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn message(&self) -> String {
self.message.clone()
}
}<|fim_prefix|>// repo: ncatelli/mud path: /mud/src/web/event.rs
extern crate serde;
extern crate serde_json;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum EventType {
Game,
}
#[derive(Serialize, Deserialize, Debug)]... | code_fim | hard | {
"lang": "rust",
"repo": "ncatelli/mud",
"path": "/mud/src/web/event.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kornholi/gd32f30x-pac path: /src/exmc/npctcfg3.rs
#[doc = "Reader of register NPCTCFG3"]
pub type R = crate::R<u32, super::NPCTCFG3>;
#[doc = "Writer for register NPCTCFG3"]
pub type W = crate::W<u32, super::NPCTCFG3>;
#[doc = "Register NPCTCFG3 `reset()`'s with value 0xfcfc_fcfc"]
impl crate::R... | code_fim | hard | {
"lang": "rust",
"repo": "kornholi/gd32f30x-pac",
"path": "/src/exmc/npctcfg3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>WAIT_R::new(((self.bits >> 8) & 0xff) as u8)
}
#[doc = "Bits 0:7 - Common memory setup time"]
#[inline(always)]
pub fn comset(&self) -> COMSET_R {
COMSET_R::new((self.bits & 0xff) as u8)
}
}
impl W {
#[doc = "Bits 24:31 - Common memory data bus HiZ time"]
#[inline(alway... | code_fim | hard | {
"lang": "rust",
"repo": "kornholi/gd32f30x-pac",
"path": "/src/exmc/npctcfg3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn write_record_sequence<W>(
writer: &mut W,
sequence: &Sequence,
line_bases: usize,
) -> io::Result<()>
where
W: Write,
{
for bases in sequence.as_ref().chunks(line_bases) {
writer.write_all(bases)?;
writeln!(writer)?;
}
Ok(())
}
#[cfg(test)]
mod tests {
... | code_fim | hard | {
"lang": "rust",
"repo": "zaeleus/noodles",
"path": "/noodles-fasta/src/writer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> writer.clear();
let sequence = Sequence::from(b"ACGTACGT".to_vec());
write_record_sequence(&mut writer, &sequence, 4)?;
assert_eq!(writer, b"ACGT\nACGT\n");
writer.clear();
let sequence = Sequence::from(b"ACGTACGTAC".to_vec());
write_record_sequence... | code_fim | hard | {
"lang": "rust",
"repo": "zaeleus/noodles",
"path": "/noodles-fasta/src/writer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn selfload_header(&self) -> Result<Option<(NESelfLoadHeader, &[u8])>, ParseError> {
if self.header.flags.contains(NEFlags::SELF_LOAD) {
Ok(Some(self.selfload_header_impl()?))
} else {
Ok(None)
}
}
/// # Arguments
/// * segment_number - 1-indexed segment number
pub fn segment_header(... | code_fim | hard | {
"lang": "rust",
"repo": "csnover/deoptloader",
"path": "/src/neexe.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn name(&self) -> Option<String> {
if self.header.non_resident_table_size == 0 {
None
} else {
let ne_non_resident_table = &self.input[self.header.non_resident_table_offset as usize..];
match read_pascal_string(&ne_non_resident_table) {
Ok((_, name)) => Some(name),
Err(_) => None... | code_fim | hard | {
"lang": "rust",
"repo": "csnover/deoptloader",
"path": "/src/neexe.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// // Ok(collected_links)
// }
/*#[cfg(test)]
mod test {
use super::*;
#[tokio::test]
async fn test_collect_links() -> Result<()> {
// let dir = tempfile::tempdir()?;
// let file_path = dir.path().join("f");
// let file_glob_1_path = dir.path().join("glob-1");
... | code_fim | hard | {
"lang": "rust",
"repo": "Excloudx6/freq-word-counter-rust",
"path": "/src/utils/traverse.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liweilijie/rust path: /basic/fs/src/fs.rs
use std::error::Error;
use std::fs::{File, OpenOptions};
use std::io::prelude::*;
use std::path::Path;
pub fn open_and_read() {
let path = Path::new("hello.txt");
let display = path.display();
let mut file = match File::open(&path) {
... | code_fim | hard | {
"lang": "rust",
"repo": "liweilijie/rust",
"path": "/basic/fs/src/fs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match file {
Ok(mut stream) => {
stream.write_all(b"hello, world!\n")?;
}
Err(err) => {
println!("{:?}", err);
}
}
Ok(())
}
// 获取目录列表
// 对文件进行操作,很可能会读取目录列表,使用fs::read_dir方法,可以获取目录列表及文件相关属性
use std::fs;
pub fn list_dir() {
if let Ok(e... | code_fim | hard | {
"lang": "rust",
"repo": "liweilijie/rust",
"path": "/basic/fs/src/fs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: escape209/chum-world path: /libchum/src/macros.rs
n.
/// Return `None` from structure for it to not appear in the structure editor.
/// * [custom_binary [type]
/// read: |value: &Self, file: &mut Write, fmt: TotemFormat| -> StructUnpackResult<[type]>;
/// write: |data: &[type], file: &mu... | code_fim | hard | {
"lang": "rust",
"repo": "escape209/chum-world",
"path": "/libchum/src/macros.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #![allow(unused_imports)]
use $crate::structure::ChumStructVariant::*;
use $crate::structure::IntType::*;
use $crate::structure::ArrayData;
use $crate::structure::ColorInfo;
Struct(vec![
$(
... | code_fim | hard | {
"lang": "rust",
"repo": "escape209/chum-world",
"path": "/libchum/src/macros.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec![
$(
stringify!($name).to_owned()
),*
]
}
}
};
}
// welcome to repretition hell
#[macro_export]
macro_rules! chum_struct_binary_read {
([ignore $type:tt $default:expr],$file:exp... | code_fim | hard | {
"lang": "rust",
"repo": "escape209/chum-world",
"path": "/libchum/src/macros.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> comp
.run()
.await
.map_err(|e| format!("TcpComp error: {:?}", e))?;
}
pub struct ParseKvsOperation;
impl Morphism for ParseKvsOperation {
type InLatRepr = SetUnionRepr<tag::SINGLE, String>;
type OutLatRepr = SetUnionRepr<tag::OPTION, KvsOperation>;
fn call<Y: Qu... | code_fim | hard | {
"lang": "rust",
"repo": "MingweiSamuel/spinach",
"path": "/examples/kvs/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
settings: ConnectionSettings,
agreement: Option<HandshakeControlInfo>,
to_send: Option<HandshakeControlInfo>,
) -> ConnectionResult {
Connected(
to_send.map(|to_send| {
(
ControlPacket {
... | code_fim | hard | {
"lang": "rust",
"repo": "russelltg/srt-rs",
"path": "/srt-protocol/src/protocol/pending_connection/rendezvous.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // fn send_agreement(&mut self, dest_sockid: SocketID, info: HandshakeVSInfo) -> ConnectionResult {
// self.send(dest_sockid, self.gen_packet(ShakeType::Agreement, info))
// }
fn make_rejection(
&self,
response_to: &HandshakeControlInfo,
timestamp: TimeStamp,
... | code_fim | hard | {
"lang": "rust",
"repo": "russelltg/srt-rs",
"path": "/srt-protocol/src/protocol/pending_connection/rendezvous.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: russelltg/srt-rs path: /srt-protocol/src/protocol/pending_connection/rendezvous.rs
}
fn extract_ext_info(
info: &HandshakeControlInfo,
) -> Result<Option<&SrtControlPacket>, ConnectError> {
match &info.info {
HandshakeVsInfo::V5(hs) => Ok(hs.ext_hs.as_ref()),
_ => Err(U... | code_fim | hard | {
"lang": "rust",
"repo": "russelltg/srt-rs",
"path": "/srt-protocol/src/protocol/pending_connection/rendezvous.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>.", label));
let ret = cb();
debug_log(format!("Finished {}: {:?}", label, t0.elapsed()));
return ret;
}<|fim_prefix|>// repo: amling/rlagar path: /src/misc.rs
use chrono::Local;
pub fn debug_log(msg: impl AsRef<str>) {
let msg = msg.as_ref();
eprintln!("{} - {}", Local::now().format... | code_fim | medium | {
"lang": "rust",
"repo": "amling/rlagar",
"path": "/src/misc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amling/rlagar path: /src/misc.rs
use chrono::Local;
pub fn debug_log(msg: impl AsRef<str>) {
let msg = msg.as_ref();
eprintln!("{} - {}", Local::now().format("%Y%m%d %H:%M:%S"), msg);
}
pub fn debug_time<T>(label: impl AsRef<str>, cb: impl FnOnce() -> T)<|fim_suffix|>.", label));
l... | code_fim | medium | {
"lang": "rust",
"repo": "amling/rlagar",
"path": "/src/misc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> bindings
.write_to_file(output_file)
.expect("Unable to write bindings!");
}
#[derive(Debug)]
struct FixAshTypes;
impl bindgen::callbacks::ParseCallbacks for FixAshTypes {
fn item_name(&self, original_item_name: &str) -> Option<String> {
if original_item_name.starts_with(... | code_fim | hard | {
"lang": "rust",
"repo": "K0bin/SourceRenderer",
"path": "/vendor/vma-sys/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let nz = $tn::splat(-$zero);
let no = $tn::splat(-$one);
let nt = $tn::splat(-$two);
let nf = $tn::splat(-$four);
assert_eq!(-z, nz);
assert_eq!(-o, no);
assert_eq!(-t, nt);
ass... | code_fim | hard | {
"lang": "rust",
"repo": "gnzlbg/stdsimd",
"path": "/coresimd/src/macros.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> *self = *self & other;
}
}
impl ::core::ops::BitOrAssign for $ty {
#[inline(always)]
fn bitor_assign(&mut self, other: Self) {
*self = *self | other;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "gnzlbg/stdsimd",
"path": "/coresimd/src/macros.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnzlbg/stdsimd path: /coresimd/src/macros.rs
$name($($elname),*)
}
#[inline(always)]
pub fn len() -> i32 {
$nelems
}
#[inline(always)]
pub const fn splat(value: $elemty) -> $name {
$na... | code_fim | hard | {
"lang": "rust",
"repo": "gnzlbg/stdsimd",
"path": "/coresimd/src/macros.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sym233/leetcode_problems path: /1010. Pairs of Songs With Total Durations Divisible by 60/1010. Pairs of Songs With Total Durations Divisible by 60.rs
impl Solution {
pub fn num_pairs_divisible_by60(time: Vec<i32>) -> i32 {
<|fim_suffix|> for &n in time.iter() {
let ... | code_fim | medium | {
"lang": "rust",
"repo": "sym233/leetcode_problems",
"path": "/1010. Pairs of Songs With Total Durations Divisible by 60/1010. Pairs of Songs With Total Durations Divisible by 60.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for &n in time.iter() {
let n = n as usize % T;
count += arr[(T - n) % T];
arr[n] += 1;
}
return count
}
}<|fim_prefix|>// repo: sym233/leetcode_problems path: /1010. Pairs of Songs With Total Durations Divisible by 60/1010. Pairs of Songs Wi... | code_fim | medium | {
"lang": "rust",
"repo": "sym233/leetcode_problems",
"path": "/1010. Pairs of Songs With Total Durations Divisible by 60/1010. Pairs of Songs With Total Durations Divisible by 60.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leandronsp/fun path: /rust/dsa/tests/008-structs.rs
// Struct allows to package together and name multiple related values
// in a meaningful group
// - Similar to Tuples, they both hold multiple related values of different types
// - Unlike Tuples, Structs hold a meaningful name
#[cfg(test)]
mod... | code_fim | hard | {
"lang": "rust",
"repo": "leandronsp/fun",
"path": "/rust/dsa/tests/008-structs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.balance = self.balance + amount;
}
fn display(&self) -> String {
format!("{}'s balance is {}", self.name, self.balance)
}
}
let mut account_a = Account {
name: "Leandro".to_string(),
balance:... | code_fim | hard | {
"lang": "rust",
"repo": "leandronsp/fun",
"path": "/rust/dsa/tests/008-structs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ConflictResolverFactory for ConflictResolverFactoryServer {
fn get_policy(&mut self, _page_id: Vec<u8>) -> Future<MergePolicy, ::fidl::Error> {
Future::done(Ok(MergePolicy_Custom))
}
/// Our resolvers are the same for every page
fn new_conflict_resolver(&mut self, _page_id: V... | code_fim | hard | {
"lang": "rust",
"repo": "xi-editor/xi-editor",
"path": "/rust/core-lib/src/fuchsia/sync.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ledger.set_conflict_resolver_factory(Some(resolver_client_ptr)).with(ledger_crash_callback);
}
struct ConflictResolverFactoryServer {
key: Vec<u8>,
}
impl ConflictResolverFactory for ConflictResolverFactoryServer {
fn get_policy(&mut self, _page_id: Vec<u8>) -> Future<MergePolicy, ::fidl::Er... | code_fim | hard | {
"lang": "rust",
"repo": "xi-editor/xi-editor",
"path": "/rust/core-lib/src/fuchsia/sync.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let world_camera: &Camera2D = unsafe {
&owner
.get_node("/root/WorldMap/CanvasLayer/WorldCamera")
.unwrap()
.assume_safe()
.cast()
.unwrap()
};
world_camera.set_position(owner.global_positio... | code_fim | hard | {
"lang": "rust",
"repo": "jguhlin/ludum-dare-47-base",
"path": "/src/player.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jguhlin/ludum-dare-47-base path: /src/player.rs
use crate::extensions::NodeExt;
use crate::state::*;
use crate::worldmap::{Direction, WorldMap};
use gdnative::api::{Camera2D, KinematicBody2D, KinematicCollision2D, Sprite, TileMap};
use gdnative::prelude::*;
use rand::prelude::*;
use std::collect... | code_fim | hard | {
"lang": "rust",
"repo": "jguhlin/ludum-dare-47-base",
"path": "/src/player.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let btnyes = unsafe {
owner.get_typed_node::<Button, _>(
"/root/WorldMap/HUD/Confirm/ColorRect/VBoxContainer/HBoxContainer/BtnYes",
)
};
let btnno = unsafe {
owner.get_typed_node::<Button, _>(
... | code_fim | hard | {
"lang": "rust",
"repo": "jguhlin/ludum-dare-47-base",
"path": "/src/player.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ERATOSTHENES);
m.insert("factorial", FACTORIAL);
m.insert("hello_world", HELLO_WORLD);
m.insert("input", INPUT);
m.insert("quine", QUINE);
m.insert("rng", RNG);
m
};
}<|fim_prefix|>// repo: JoshKarpel/fungoid path: /src/examples.rs
use std::collections:... | code_fim | hard | {
"lang": "rust",
"repo": "JoshKarpel/fungoid",
"path": "/src/examples.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Copy, Clone, Debug, Display)]
pub struct Rsa3072Seal;
impl StaticSealedIO for Rsa3072Seal {
type Error = Error;
type Unsealed = Rsa3072KeyPair;
fn unseal_from_static_file() -> Result<Self::Unsealed> {
let raw = unseal(RSA3072_SEALED_KEY_FILE)?;
let key: Rsa3072KeyPair = serde_json... | code_fim | hard | {
"lang": "rust",
"repo": "encointer/encointer-worker",
"path": "/core-primitives/sgx/crypto/src/rsa3072.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn seal_to_static_file(unsealed: &Self::Unsealed) -> Result<()> {
let key_json = serde_json::to_vec(&unsealed)
.map_err(|e| Error::Other(format!("{:?}", e).into()))?;
Ok(seal(&key_json, RSA3072_SEALED_KEY_FILE)?)
}
}
impl SealedIO for Rsa3072Seal {
type Error = Error;
type Unsealed = ... | code_fim | hard | {
"lang": "rust",
"repo": "encointer/encointer-worker",
"path": "/core-primitives/sgx/crypto/src/rsa3072.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {
n:usize,
}
let n = n * 108 / 100;
if n < 206 {
println!("Yay!");
} else if n == 206 {
println!("so-so");
} else {
println!(":(");
}
}<|fim_prefix|>// repo: matsutake-eg/atcoder path: /rust/abc206/src/bin/a.rs
#![allow(unused_imports)]
... | code_fim | medium | {
"lang": "rust",
"repo": "matsutake-eg/atcoder",
"path": "/rust/abc206/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matsutake-eg/atcoder path: /rust/abc206/src/bin/a.rs
#![allow(unused_imports)]
use itertools::Itertools;
use itertools_num::ItertoolsNum as _;
use num_integer::*;
use petgraph::*;
use proconio::{fastout, input, marker::*};
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;
use su... | code_fim | medium | {
"lang": "rust",
"repo": "matsutake-eg/atcoder",
"path": "/rust/abc206/src/bin/a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n = n * 108 / 100;
if n < 206 {
println!("Yay!");
} else if n == 206 {
println!("so-so");
} else {
println!(":(");
}
}<|fim_prefix|>// repo: matsutake-eg/atcoder path: /rust/abc206/src/bin/a.rs
#![allow(unused_imports)]
use itertools::Itertools;
use itertoo... | code_fim | medium | {
"lang": "rust",
"repo": "matsutake-eg/atcoder",
"path": "/rust/abc206/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: muzudho/rust-kifuwarabe-wcsc29-lib path: /src/live/best_move_picker.rs
app.comm.println(&format!(
"[#Change thread: subject:{}, not empty]",
subject_piece_id.to_human_presentable_4width(),
));
}
// 中身... | code_fim | hard | {
"lang": "rust",
"repo": "muzudho/rust-kifuwarabe-wcsc29-lib",
"path": "/src/live/best_move_picker.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 今探している駒の指し手のような感じはするみたいだな☆(^~^)
if app.is_debug() {
app.comm.println(&format!(
"\n----------------------------------------[#Hit note! sought_move_result: {:?}, Move {}... | code_fim | hard | {
"lang": "rust",
"repo": "muzudho/rust-kifuwarabe-wcsc29-lib",
"path": "/src/live/best_move_picker.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// この指し手が、今探している駒の指し手のものであるのか判定。
pub fn match_subject_piece(
&mut self,
subject_piece_id: PieceIdentify,
my_addr_obj: Address,
bmove: &BestMove,
board_size: BoardSize,
app: &Application,
) -> bool {
if subject_piece_id.get_number() != bm... | code_fim | hard | {
"lang": "rust",
"repo": "muzudho/rust-kifuwarabe-wcsc29-lib",
"path": "/src/live/best_move_picker.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nlinker/rust-graphql-json path: /src/main.rs
#[macro_use]
extern crate serde_json;
mod graphql;
mod graphql_json;
use crate::graphql::{schema, Context};
use std::env;
use warp::{http::Response, Filter};
#[tokio::main]
async fn main() {
env::set_var("RUST_LOG", "warp_server");
env_logg... | code_fim | hard | {
"lang": "rust",
"repo": "nlinker/rust-graphql-json",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> warp::serve(
warp::get()
.and(warp::path("playground"))
.and(juniper_warp::playground_filter("/graphql", None))
.or(homepage)
.or(warp::path("graphql").and(graphql_filter))
.with(log),
)
.run(([127, 0, 0, 1], 8080))
.await... | code_fim | medium | {
"lang": "rust",
"repo": "nlinker/rust-graphql-json",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let merger = Merger::from_config_file(matches.value_of("config").unwrap())
.unwrap_or_else(|e| die(e));
merger
.run(matches.is_present("auto"))
.unwrap_or_else(|e| die(e));
}
fn die(err: impl Error) -> ! {
println!("{}", err);
std::process::exit(1);
}<|fim_prefix|>// repo: mmcclimon/... | code_fim | hard | {
"lang": "rust",
"repo": "mmcclimon/rustmergency",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
P: TriplesParser,
<P as TriplesParser>::Error: 'static,
{
p.into_iter(|t| -> Result<_, Berr> { Ok(triple(t)?) })
.collect::<Result<Vec<om::Triple>, Berr>>()?
.into_iter()
.pipe(Graph::new)
.pipe(Ok)
}
match cont... | code_fim | hard | {
"lang": "rust",
"repo": "docknetwork/quaerit-machina",
"path": "/examples/crawl/crawl.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: docknetwork/quaerit-machina path: /examples/crawl/crawl.rs
extern crate core;
mod rm_to_om;
use async_trait::async_trait;
use core::fmt::Debug;
use oxigraph::io::DatasetFormat;
use oxigraph::model as om;
use oxigraph::model::NamedNode;
use oxigraph::MemoryStore;
use quaerit_machina::LookupErro... | code_fim | hard | {
"lang": "rust",
"repo": "docknetwork/quaerit-machina",
"path": "/examples/crawl/crawl.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct ProgramState {
pub mem: Memory,
pub regs: Registers,
}
impl fmt::Display for ProgramState {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "Memory map: {:x}", self.mem)?;
write!(f, "{}", self.regs)?;
Ok(()... | code_fim | hard | {
"lang": "rust",
"repo": "whentze/raik",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whentze/raik path: /src/lib.rs
#![allow(non_camel_case_types)]
use std::fmt;
extern crate byteorder;
pub mod instruction;
#[derive(Debug, Clone)]
pub struct Memory {
pub data: Vec<u8>,
}
impl fmt::LowerHex for Memory {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {... | code_fim | hard | {
"lang": "rust",
"repo": "whentze/raik",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn interpret(&mut self, stmt: Stmt) {
// println!("Compiling {:?}", stmt.var);
// println!("Raw: {:?}", stmt.code);
let v = self.compile(stmt.code);
// println!("Compiled: {:?}", v);
self.vars.insert(stmt.var, v);
}
fn compile(&self, code: Vec<Token... | code_fim | hard | {
"lang": "rust",
"repo": "coffeecup-winner/icfpc2020",
"path": "/src/eval.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Token::Number(n) => stack.push(number(n)),
Token::True => stack.push(b(BuiltIn::True)),
Token::False => stack.push(b(BuiltIn::False)),
Token::Nil => stack.push(b(BuiltIn::Nil)),
Token::Inc => stack.push(b(BuiltIn::Inc)),
... | code_fim | hard | {
"lang": "rust",
"repo": "coffeecup-winner/icfpc2020",
"path": "/src/eval.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lakret/aoc2020 path: /src/d06.rs
use std::collections::HashSet;
pub fn solve(input: &str) -> Option<Box<usize>> {
let sum_of_counts = input
.trim_end()
.split("\n\n")
.map(|group| group.chars().filter(|ch| *ch != '\n').collect::<HashSet<_>>().len())
.sum();
Some(Box::new(su... | code_fim | medium | {
"lang": "rust",
"repo": "Lakret/aoc2020",
"path": "/src/d06.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use std::fs;
#[test]
fn part_one_works_with_sample() {
let input = fs::read_to_string("inputs/sample06").unwrap();
assert_eq!(solve(&input), Some(Box::new(11)));
}
#[test]
fn part_two_works_with_sample() {
let input = fs::read_to_string("i... | code_fim | hard | {
"lang": "rust",
"repo": "Lakret/aoc2020",
"path": "/src/d06.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let scalar_1 = rand_32_bytes();
let point_1 = g!({ Scalar::from_bytes_mod_order(scalar_1.clone()) } * G);
let secp_pk_1 =
PublicKey::from_secret_key(&secp, &SecretKey::from_slice(&scalar_1).unwrap());
assert_eq!(
(g!(point_1 + point_1))
... | code_fim | hard | {
"lang": "rust",
"repo": "comit-network/secp256kfun",
"path": "/secp256kfun/tests/against_c_lib.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = rrrdb
.execute("test_db", "SELECT name FROM users WHERE id = 2")
.unwrap();
assert_eq!(
result,
OkDBResult::SelectResult(ResultSet::new(
vec![Record::new(vec![FieldValue::Text("Bob".to_string()),]),],
... | code_fim | hard | {
"lang": "rust",
"repo": "yukibtc/rrrdb",
"path": "/src/rrrdb.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use std::{
path::Path,
thread::{self, sleep},
time,
};
use super::{
schema::{store::SchemaStore, *},
*,
};
#[test]
fn run() {
let mut rrrdb = build_crean_database();
rrrdb
.execute("test_... | code_fim | hard | {
"lang": "rust",
"repo": "yukibtc/rrrdb",
"path": "/src/rrrdb.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: twistedfall/opencv-rust path: /docs/features2d.rs
ain_data: bool) -> Result<core::Ptr<crate::features2d::DescriptorMatcher>> {
return_send!(via ocvrs_return);
unsafe { sys::cv_DescriptorMatcher_clone_const_bool(self.as_raw_DescriptorMatcher(), empty_train_data, ocvrs_return.as_mut_ptr()) }... | code_fim | hard | {
"lang": "rust",
"repo": "twistedfall/opencv-rust",
"path": "/docs/features2d.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: twistedfall/opencv-rust path: /docs/features2d.rs
), ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
#[inline]
fn get_pass2_only(&self) -> Result<bool> {
return_send!(via ocvrs_return);
unsafe { sys::cv_MS... | code_fim | hard | {
"lang": "rust",
"repo": "twistedfall/opencv-rust",
"path": "/docs/features2d.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> return_send!(via ocvrs_return);
unsafe { sys::cv_AffineFeature_getViewParams_const_vectorLfloatGR_vectorLfloatGR(self.as_raw_AffineFeature(), tilts.as_raw_mut_VectorOff32(), rolls.as_raw_mut_VectorOff32(), ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret... | code_fim | hard | {
"lang": "rust",
"repo": "twistedfall/opencv-rust",
"path": "/docs/features2d.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kunalmohan/dodge-game path: /src/main.rs
le_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &obstacle_bind_group_layout,
bindings: &[
wgpu::Binding {
binding: 0,
resource: wgpu::BindingResource::Buffer {
buf... | code_fim | hard | {
"lang": "rust",
"repo": "kunalmohan/dodge-game",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kunalmohan/dodge-game path: /src/main.rs
ion: [0.2, -0.2, 0.2], color: [0.9, 0.2, 0.2], normal: [0.0, 0.0, 1.0] },
Vertex { position: [0.2, -0.2, 0.2], color: [0.9, 0.2, 0.2], normal: [0.0, 0.0, 1.0] },
Vertex { position: [-0.2, -0.2, 0.2], color: [0.9, 0.2, 0.2], normal: [0.0,... | code_fim | hard | {
"lang": "rust",
"repo": "kunalmohan/dodge-game",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let uniform_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &uniform_bind_group_layout,
bindings: &[
wgpu::Binding {
binding: 0,
resource: wgpu::BindingResource::Buffer {
buffer: &uniform_buffer,
r... | code_fim | hard | {
"lang": "rust",
"repo": "kunalmohan/dodge-game",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.out.is_none() {
return;
}
let offset: Point;
if override_offset || self.render_offset.is_none() { offset = Point { x: 0, y: 0 }; } else { offset = self.render_offset.unwrap(); }
let output = self.out.as_mut().unwrap();
output.queue(MoveT... | code_fim | hard | {
"lang": "rust",
"repo": "DoorOfLife/Tootris",
"path": "/src/ui/crossterm_render.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rec = receiver.try_recv();
if rec.is_ok() {
let com = rec.unwrap();
if com.level.is_some() {
self.update_matrix(com.level.unwrap());
return true;
}
if com.state.is_some() {
self.state = com.... | code_fim | hard | {
"lang": "rust",
"repo": "DoorOfLife/Tootris",
"path": "/src/ui/crossterm_render.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DoorOfLife/Tootris path: /src/ui/crossterm_render.rs
use std::borrow::{BorrowMut, Borrow};
use std::io::{Stdout, Write};
use crossterm::{
cursor,
QueueableCommand, style::{self}, terminal,
};
use crossterm::style::{Color, Styler};
use crossterm::terminal::ClearType;
use crate::game::to... | code_fim | hard | {
"lang": "rust",
"repo": "DoorOfLife/Tootris",
"path": "/src/ui/crossterm_render.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::test]
async fn get_historic_rates() {
let exchange = init().await;
let req = GetHistoricRatesRequest {
market_pair: "eth_btc".to_string(),
interval: Interval::OneHour,
paginator: None,
};
let resp = exchange.get_historic_rates(&req).await.unwrap();
prin... | code_fim | hard | {
"lang": "rust",
"repo": "TradeSmart/openlimits",
"path": "/tests/nash/market.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(KeyPress { key, mods })
})
.collect()
}
}
impl Display for KeyPress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.mods.contains(ModifiersState::CONTROL) {
let _ = f.write_str("Ctrl+");
}
... | code_fim | hard | {
"lang": "rust",
"repo": "lapce/lapce",
"path": "/lapce-app/src/keypress/press.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lapce/lapce path: /lapce-app/src/keypress/press.rs
use std::fmt::Display;
use floem::keyboard::{Key, ModifiersState};
use tracing::warn;
use super::key::KeyInput;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct KeyPress {
pub(super) key: KeyInput,
pub(super) mods: ModifiersSta... | code_fim | hard | {
"lang": "rust",
"repo": "lapce/lapce",
"path": "/lapce-app/src/keypress/press.rs",
"mode": "psm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Camera
let camera = Camera::new(
look_from,
look_at,
Vec3::new(0.0, 1.0, 0.0),
20.0,
aspect_ratio,
0.1,
10.0,
);
// World
let world = World::get_world(true);
let color_handle = thread::spawn(move || {
pixels::pixe... | code_fim | medium | {
"lang": "rust",
"repo": "DivineStride/Another-Simple-Ray-Tracer",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // World
let world = World::get_world(true);
let color_handle = thread::spawn(move || {
pixels::pixel_loop(
&camera,
&world,
image_width,
image_height,
samples_per_pixel,
max_depth,
stats_tx,
... | code_fim | hard | {
"lang": "rust",
"repo": "DivineStride/Another-Simple-Ray-Tracer",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
is_permutation(&String::from("asdf"), &String::from("dsaf")),
true
);
assert_eq!(is_permutation("asdf", "safd"), true);
assert_eq!(is_permutation("asdf", "zsdf"), false);
assert_eq!(is_permutation("alex", "alet"), false);
}
}<... | code_fim | hard | {
"lang": "rust",
"repo": "shreyasdamle/rust_101",
"path": "/src/ctci_02.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut map: HashMap<char, i32> = HashMap::new();
for c in s.chars() {
if let Some(count) = map.get_mut(&c) {
*count += 1;
} else {
map.insert(c, 1);
}
}
map
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_is_permutati... | code_fim | medium | {
"lang": "rust",
"repo": "shreyasdamle/rust_101",
"path": "/src/ctci_02.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Default, Component)]
#[storage(NullStorage)]
pub struct PlayerController;<|fim_prefix|>// repo: MattWoelk/rust-roguelike path: /src/components.rs
use specs::{Component, NullStorage, VecStorage};
use specs_derive::Component;
#[derive(Debug, PartialEq, Component)]
#[storage(VecStorage)]
pu... | code_fim | medium | {
"lang": "rust",
"repo": "MattWoelk/rust-roguelike",
"path": "/src/components.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /src/scene/mesh/buffer.rs
ys)]
fn read_4_u8(&self, usage: VertexAttributeUsage) -> Result<Vector4<u8>, VertexFetchError> {
let (data, layout) = self.data_layout_ref();
if let Some(attribute) = layout.get(usage as usize).unwrap() {
let offse... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/src/scene/mesh/buffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /src/scene/mesh/buffer.rs
&self, usage: VertexAttributeUsage) -> Result<Vector2<f32>, VertexFetchError> {
let (data, layout) = self.data_layout_ref();
if let Some(attribute) = layout.get(usage as usize).unwrap() {
let x = LittleEndian::read_f32... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/src/scene/mesh/buffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Read/write accessor for a vertex with some layout.
#[derive(Debug)]
pub struct VertexViewMut<'a> {
vertex_data: &'a mut [u8],
sparse_layout: &'a [Option<VertexAttribute>],
}
impl<'a> PartialEq for VertexViewMut<'a> {
fn eq(&self, other: &Self) -> bool {
self.vertex_data == other.v... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/src/scene/mesh/buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).baz3) as usize - ptr as usize },
8usize,
concat!("Offset of field: ", stringify!(Bar), "::", stringify!(baz3)),
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).baz4) as usize - ptr as usize },
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-bindgen",
"path": "/bindgen-tests/tests/expectations/tests/constify-module-enums-simple-alias.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn roll(die: i32) -> i32 {
let mut rng = rand::thread_rng();
rng.gen_range(1, die)
}
fn roll_with_advantage(die: i32) -> (i32, i32) {
let mut rng = rand::thread_rng();
let roll1 = rng.gen_range(1, die);
let roll2 = rng.gen_range(1, die);
return if roll1 > roll2 { (roll1, roll2) } else { (roll... | code_fim | hard | {
"lang": "rust",
"repo": "danambrogio/roll20",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> track.album = tag.album().map(|x| x.to_string());
track.interpret = tag.artist().map(|x| x.to_string());
track.composer = tag.artist().map(|x| x.to_string());
} else {
track.title = Some(file.file_stem().unwrap().t... | code_fim | hard | {
"lang": "rust",
"repo": "bytesnake/hex",
"path": "/cli/src/store.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Only for authorities?
if slash.flags.authority() {
match check_authority(ctx, user_id, command.guild_id).await {
Ok(None) => {}
Ok(Some(content)) => {
command.error_callback(ctx, content).await?;
return Ok(Some(ProcessResult::NoAu... | code_fim | hard | {
"lang": "rust",
"repo": "MaxOhn/Bathbot",
"path": "/bathbot/src/core/events/interaction/command.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.