text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let data_lines = vec![
BedGraphDataLine::<f32> {
chrom: "chr1".into(),
start: 3,
end_exclusive: 10,
value: 5.,
},
BedGraphDataLine {
chrom: "chr1".into(),
start: 0,
... | code_fim | hard | {
"lang": "rust",
"repo": "Rustinante/biofile",
"path": "/src/bed/bed_writer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_expected_bed_data_lines<D: Copy + Num>(
original_data_lines: &[BedDataLine<D>],
) -> Vec<BedDataLine<D>> {
original_data_lines
.iter()
.enumerate()
.map(|(i, l)| BedDataLine {
chrom: l.chrom.clone(),
start: ... | code_fim | hard | {
"lang": "rust",
"repo": "Rustinante/biofile",
"path": "/src/bed/bed_writer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rustinante/biofile path: /src/bed/bed_writer.rs
use crate::{bed::BedDataLine, bedgraph::BedGraphDataLine, util::Strand};
use num::Float;
use std::{
fs::{File, OpenOptions},
io::{BufWriter, Write},
};
pub struct BedWriter {
path: String,
writer: BufWriter<File>,
num_lines_wri... | code_fim | hard | {
"lang": "rust",
"repo": "Rustinante/biofile",
"path": "/src/bed/bed_writer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danbev/learning-rust path: /snippets/src/clone.rs
#[cfg(test)]
mod tests {
#[test]
fn format_test() {
let x = 10;
let y = x.clone();
println!("clone y: {}", y);
<|fim_suffix|> let s3:&str = "bajja3";
println!("{}", s3);
println!("clone {}",... | code_fim | medium | {
"lang": "rust",
"repo": "danbev/learning-rust",
"path": "/snippets/src/clone.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s = "bajja1".to_string();
let mut s2 = String::from("bajja2");
println!("{}, {}", s, s2);
let s3:&str = "bajja3";
println!("{}", s3);
println!("clone {}", &s3[..]);
}
}<|fim_prefix|>// repo: danbev/learning-rust path: /snippets/src/clone.rs
#[c... | code_fim | medium | {
"lang": "rust",
"repo": "danbev/learning-rust",
"path": "/snippets/src/clone.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! primitive_impl(
($t: ty, $expr: expr) => (
impl CLType for $t {
fn to_cl_type_str(_: Option<$t>) -> ~str {
~$expr
}
fn to_cl_literal_str(&self) -> ~str {
self.to_str()
}
}
)
)
primitive_i... | code_fim | hard | {
"lang": "rust",
"repo": "sebcrozet/rs2cl",
"path": "/src/cl_type.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sebcrozet/rs2cl path: /src/cl_type.rs
pub trait CLType {
fn to_cl_type_str(dummy_self: Option<Self>) -> ~str;
fn to_cl_literal_str(&self) -> ~str;
}
impl<T: CLType> CLType for ~[T] {
fn to_cl_type_str(_: Option<~[T]>) -> ~str {
CLType::to_cl_type_str(None::<T>) + "*"
}
... | code_fim | hard | {
"lang": "rust",
"repo": "sebcrozet/rs2cl",
"path": "/src/cl_type.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ~$expr
}
fn to_cl_literal_str(&self) -> ~str {
self.to_str()
}
}
)
)
primitive_impl!(i32, "int")
primitive_impl!(i64, "long")
primitive_impl!(u32, "unsigned int")
primitive_impl!(u64, "unsigned long")
primitive_impl!(f32... | code_fim | medium | {
"lang": "rust",
"repo": "sebcrozet/rs2cl",
"path": "/src/cl_type.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zcash/halo2 path: /halo2_proofs/src/circuit/table_layouter.rs
//! Implementations of common table layouters.
use std::{
collections::HashMap,
fmt::{self, Debug},
};
use ff::Field;
use crate::plonk::{Assigned, Assignment, Error, TableColumn, TableError};
use super::Value;
/// Helper ... | code_fim | hard | {
"lang": "rust",
"repo": "zcash/halo2",
"path": "/halo2_proofs/src/circuit/table_layouter.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn table_uneven_columns() {
const K: u32 = 4;
#[derive(Clone)]
struct FaultyCircuitConfig {
table: (TableColumn, TableColumn),
}
struct FaultyCircuit;
impl Circuit<Fp> for FaultyCircuit {
type Config = FaultyCircuit... | code_fim | hard | {
"lang": "rust",
"repo": "zcash/halo2",
"path": "/halo2_proofs/src/circuit/table_layouter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_state.diamonds[ idx ] = diamond_pos;
}
moves.push( (new_state, mov.1.clone()) );
}
moves
}
fn draw_map( state: & State, map: & Map ) {
for (y, line) in map.iter().enumerate() {
let mut line = line.clone();
if state.guy.1 as usize == y { line[ ... | code_fim | hard | {
"lang": "rust",
"repo": "MarWit/University",
"path": "/ArtificialIntelligence/assignment2/sokoban/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MarWit/University path: /ArtificialIntelligence/assignment2/sokoban/src/main.rs
use std::collections::{VecDeque, HashSet, BinaryHeap};
use std::collections::hash_map::{HashMap, Entry};
use std::cmp::Ordering;
use std::fs;
use std::io::{self, Write, BufRead, BufReader};
type Map = Vec<Vec<char>>... | code_fim | hard | {
"lang": "rust",
"repo": "MarWit/University",
"path": "/ArtificialIntelligence/assignment2/sokoban/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> fmt::Display for HostentBorrowed<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let hostent = self.hostent();
display(hostent, fmt)
}
}
unsafe impl<'a> Send for HostentBorrowed<'a> {}
unsafe impl<'a> Sync for HostentBorrowed<'a> {}
// Get an IpAddr from a... | code_fim | hard | {
"lang": "rust",
"repo": "dimbleby/rust-c-ares",
"path": "/src/hostent.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Iterator for HostAddressResultsIter<'a> {
type Item = IpAddr;
fn next(&mut self) -> Option<Self::Item> {
let h_addr = *self.next;
if h_addr.is_null() {
None
} else {
unsafe {
self.next = &*(self.next as *const *const c_char).... | code_fim | hard | {
"lang": "rust",
"repo": "dimbleby/rust-c-ares",
"path": "/src/hostent.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dimbleby/rust-c-ares path: /src/hostent.rs
use std::ffi::CStr;
use std::fmt;
use std::marker::PhantomData;
use std::mem;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::os::raw::{c_char, c_int};
use std::slice;
use itertools::Itertools;
use crate::types::AddressFamily;
use crate::utils::a... | code_fim | hard | {
"lang": "rust",
"repo": "dimbleby/rust-c-ares",
"path": "/src/hostent.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// `DelegatedProposer` is a transient construct only created on the
/// node doing all block proposals, it is responsible for doing the
/// infinite loop of block creation. It needs access to the private
/// key corresponding to the ID of the only actor allowed to sign
/// blocks.
pub struct DelegatedPro... | code_fim | hard | {
"lang": "rust",
"repo": "lyswifter/forest",
"path": "/blockchain/consensus/deleg_cns/src/proposer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lyswifter/forest path: /blockchain/consensus/deleg_cns/src/proposer.rs
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use anyhow::anyhow;
use async_std::stream::interval;
use async_trait::async_trait;
use core::time::Duration;
use futures::StreamExt;
use log... | code_fim | hard | {
"lang": "rust",
"repo": "lyswifter/forest",
"path": "/blockchain/consensus/deleg_cns/src/proposer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(GossipBlock {
header,
bls_messages: persisted.bls_cids,
secpk_messages: persisted.secp_cids,
})
}
}
#[async_trait]
impl Proposer for DelegatedProposer {
async fn run<DB, MP>(
self,
state_manager: Arc<StateManager<DB>>,
... | code_fim | hard | {
"lang": "rust",
"repo": "lyswifter/forest",
"path": "/blockchain/consensus/deleg_cns/src/proposer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hashmismatch/packed_struct.rs path: /packed_struct_tests/tests/enum_packing_2.rs
use packed_struct::prelude::*;
#[allow(non_camel_case_types)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PrimitiveEnum_u8)]
#[repr(u8)]
pub enum DataRate {
/// No output data is produced.
PowerDown = 0,
... | code_fim | hard | {
"lang": "rust",
"repo": "hashmismatch/packed_struct.rs",
"path": "/packed_struct_tests/tests/enum_packing_2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = ControlRegister4 {
output_data_rate: DataRate::Rate6_25Hz,
z_axis_enabled: true
};
let b = r.pack().unwrap();
assert_eq!([0b00010010], b);
}<|fim_prefix|>// repo: hashmismatch/packed_struct.rs path: /packed_struct_tests/tests/enum_packing_2.rs
use packed_struct::p... | code_fim | hard | {
"lang": "rust",
"repo": "hashmismatch/packed_struct.rs",
"path": "/packed_struct_tests/tests/enum_packing_2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Erguotou/lpc-pac path: /lpc54608/src/dmic0/channel/phy_ctrl.rs
#[doc = "Reader of register PHY_CTRL"]
pub type R = crate::R<u32, super::PHY_CTRL>;
#[doc = "Writer for register PHY_CTRL"]
pub type W = crate::W<u32, super::PHY_CTRL>;
#[doc = "Register PHY_CTRL `reset()`'s with value 0"]
impl crate... | code_fim | hard | {
"lang": "rust",
"repo": "Erguotou/lpc-pac",
"path": "/lpc54608/src/dmic0/channel/phy_ctrl.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Reader of field `PHY_HALF`"]
pub type PHY_HALF_R = crate::R<bool, PHY_HALF_A>;
impl PHY_HALF_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> PHY_HALF_A {
match self.bits {
false => PHY_HALF... | code_fim | hard | {
"lang": "rust",
"repo": "Erguotou/lpc-pac",
"path": "/lpc54608/src/dmic0/channel/phy_ctrl.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spacejam/tikv-client path: /examples/simple.rs
extern crate futures;
extern crate tokio;
extern crate tokio_redis as redis;
extern crate env_logger;
use futures::Future;
use tokio::Service;
use redis::{Client, Cmd};
pub fn main() {
env_logger::init().unwrap();
let addr = "127.0.0.1:63... | code_fim | hard | {
"lang": "rust",
"repo": "spacejam/tikv-client",
"path": "/examples/simple.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let c2 = c1.clone();
let r = c1.set("zomghi2u", "SOME VALUE")
.and_then(move |_| c2.get("zomghi2u"))
;
// let resp = client.get("zomghi2u");
// let resp = client.call("Hello".to_string());
println!("RESPONSE: {:?}", await(r));
}
// Why this isn't in futures-rs, I do... | code_fim | hard | {
"lang": "rust",
"repo": "spacejam/tikv-client",
"path": "/examples/simple.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = c1.set("zomghi2u", "SOME VALUE")
.and_then(move |_| c2.get("zomghi2u"))
;
// let resp = client.get("zomghi2u");
// let resp = client.call("Hello".to_string());
println!("RESPONSE: {:?}", await(r));
}
// Why this isn't in futures-rs, I do not know...
fn await<T: F... | code_fim | medium | {
"lang": "rust",
"repo": "spacejam/tikv-client",
"path": "/examples/simple.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>6_22;
pub mod ex16_23;
pub mod ex16_24;
pub mod ex16_25;
pub mod ex16_26;<|fim_prefix|>// repo: jabcross/My-CtCI-Solutions path: /rust/src/chapter_16/mod.rs
#![allow(clippy::needless_range_loop)]
#![allow(clippy::len_zero)]
#![al<|fim_middle|>low(clippy::comparison_chain)]
pub mod ex16_16;
pub mod ex16_... | code_fim | medium | {
"lang": "rust",
"repo": "jabcross/My-CtCI-Solutions",
"path": "/rust/src/chapter_16/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jabcross/My-CtCI-Solutions path: /rust/src/chapter_16/mod.rs
#![allow(clippy::needless_range_loop)]
#![allow(clippy::len_zero)]
#![al<|fim_suffix|> ex16_18;
pub mod ex16_19;
pub mod ex16_20;
pub mod ex16_21;
pub mod ex16_22;
pub mod ex16_23;
pub mod ex16_24;
pub mod ex16_25;
pub mod ex16_26;<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "jabcross/My-CtCI-Solutions",
"path": "/rust/src/chapter_16/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SimpleCurve {
fn translate(&mut self, t: f64) -> f64 {
use std::f64::consts::PI;
match self {
Self::Linear => t,
Self::EaseIn => t * t,
Self::EaseOut => t * (2.0 - t),
Self::EaseInOut => {
let t = t * 2.0;
... | code_fim | hard | {
"lang": "rust",
"repo": "njust/druid-widget-nursery",
"path": "/src/animation/curve.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> AnimationCurve::Simple(SimpleCurve::Linear)
}
}
impl AnimationCurve {
pub fn translate(&mut self, t: f64) -> f64 {
match self {
Self::Simple(s) => s.translate(t),
Self::Custom(c) => c.translate(t),
}
}
pub fn from_closure(f: impl FnMut(f64)... | code_fim | hard | {
"lang": "rust",
"repo": "njust/druid-widget-nursery",
"path": "/src/animation/curve.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: njust/druid-widget-nursery path: /src/animation/curve.rs
use std::fmt;
use std::fmt::{Debug, Formatter};
use druid::Data;
/// A custom animation curve mapping from time in the range 0..1 to progress in a range "around" 0..1.
/// It is permissible to undershoot and overshoot.
pub enum CustomCur... | code_fim | hard | {
"lang": "rust",
"repo": "njust/druid-widget-nursery",
"path": "/src/animation/curve.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = Some(Rc::new(RefCell::new(TreeNode {
val: 3,
left: Some(Rc::new(RefCell::new(TreeNode {
val: 1,
left: None,
right: Some(Rc::new(RefCell::new(TreeNode {
val: 2,
left: None,
... | code_fim | hard | {
"lang": "rust",
"repo": "LyunKi/rust-algorithm",
"path": "/src/delete_node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LyunKi/rust-algorithm path: /src/delete_node.rs
use std::cell::RefCell;
use std::rc::Rc;
use TreeNode;
#[allow(dead_code)]
pub fn delete_node(root: Option<Rc<RefCell<TreeNode>>>, key: i32) -> Option<Rc<RefCell<TreeNode>>> {
if root.is_some() {
let inner = root.clone().unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "LyunKi/rust-algorithm",
"path": "/src/delete_node.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foresterre/cargo-msrv path: /src/writer/toolchain_file.rs
use crate::combinators::ThenSome;
use crate::error::{IoError, IoErrorSource};
use crate::reporter::event::{
AuxiliaryOutput, AuxiliaryOutputItem, Destination, ToolchainFileKind,
};
use crate::reporter::Reporter;
use crate::{semver, TR... | code_fim | hard | {
"lang": "rust",
"repo": "foresterre/cargo-msrv",
"path": "/src/writer/toolchain_file.rs",
"mode": "psm",
"license": "Unicode-DFS-2016",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tmp = TestDir::temp().create("rust-toolchain", FileType::EmptyFile);
let root = tmp.root();
let root = Utf8Path::from_path(root).unwrap();
let toolchain_file = toolchain_file(root);
assert_eq!(toolchain_file, root.join("rust-toolchain"));
}
#[test]
... | code_fim | hard | {
"lang": "rust",
"repo": "foresterre/cargo-msrv",
"path": "/src/writer/toolchain_file.rs",
"mode": "spm",
"license": "Unicode-DFS-2016",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 2pi is the same as 0
if (self.theta - 2.0 * f64::consts::PI).abs() < EPSILON {
self.theta = 0.0;
}
// update position
self.pos.x = x + self.orbit_diameter * self.theta.cos();
self.pos.y = y + self.orbit_diameter * self.theta.sin();
/... | code_fim | hard | {
"lang": "rust",
"repo": "lhernandezcruz/hit_n_run",
"path": "/src/weapons/orb.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lhernandezcruz/hit_n_run path: /src/weapons/orb.rs
extern crate rand;
use rand::Rng;
use vector::Vector;
use std::f64;
use constants::orb_constants::*;
/// Orbs
pub struct Orb {
/// Whether the orb is active or not
active: bool,
/// The angle at which it is found
theta: f64,
... | code_fim | hard | {
"lang": "rust",
"repo": "lhernandezcruz/hit_n_run",
"path": "/src/weapons/orb.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct Scale {
pub min: f64,
pub max: f64,
}
impl Scale {
pub fn new(min:f64,max:f64) -> Self {
Self {
min: min,
max: max,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)... | code_fim | hard | {
"lang": "rust",
"repo": "larorg/wqa",
"path": "/wqa-canbus/src/pre/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: larorg/wqa path: /wqa-canbus/src/pre/mod.rs
//! Sensor
//! NDir1,NDir2 ,Zirox NO
//!
//!
pub mod airflow;
pub mod humidity;
pub mod pressure;
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct Range {
pub min:f64,
pub max... | code_fim | hard | {
"lang": "rust",
"repo": "larorg/wqa",
"path": "/wqa-canbus/src/pre/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: morimolymoly/rust-is-fun path: /ownership/src/main.rs
fn main() {
let s1: String = String::from("hello");
println!("s1 is {}", s1);
let s2 = s1;
println!("s1 moved to s2!");
//println!("s1 is {}", s1);
// printstr(String::from("s1 is"), s2);
printstr_by_ref(String::fr... | code_fim | hard | {
"lang": "rust",
"repo": "morimolymoly/rust-is-fun",
"path": "/ownership/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> s
}
// 参照している値はスコープを抜けたらDropされて無効な値になる!!
/*
fn dangle() -> &String {
let s1: String = String::from("ssss");
&s1
}*/
// 所有権をmoveさせてやりゃいい
fn no_dangle() -> String {
let s1: String = String::from("sss");
s1
}<|fim_prefix|>// repo: morimolymoly/rust-is-fun path: /ownership/src/main.rs
f... | code_fim | hard | {
"lang": "rust",
"repo": "morimolymoly/rust-is-fun",
"path": "/ownership/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (line_index, line) in get_lines_to_render(
&cursor.lines,
camera_line as usize,
scroll_height_in_lines.ceil() as usize,
)
.enumerate()
{
let line_y_offset = get_character_y(line_index as i32... | code_fim | hard | {
"lang": "rust",
"repo": "danielbartsch/editor",
"path": "/src/editor/ui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielbartsch/editor path: /src/editor/ui.rs
#[path = "cursor.rs"]
mod cursor;
#[path = "text_rendering.rs"]
mod text_rendering;
pub mod editor {
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use sdl2::rect::Point;
use sdl2::render::WindowCan... | code_fim | hard | {
"lang": "rust",
"repo": "danielbartsch/editor",
"path": "/src/editor/ui.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for color in colors {
let mut ul = colors::ansi::ColorAnsi::new(None, None);
ul.underline(true);
let mut ulb = colors::ansi::ColorAnsi::new(None, None);
ulb.underline(true);
ulb.bold(true);
let triad = color.triad();
let tetradic = color.tetrad... | code_fim | hard | {
"lang": "rust",
"repo": "L3afMe/colou-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for color in colors {
let hsv = colors::hsv::HSVColor::from(color);
let hsl = colors::hsl::HSLColor::from(color);
let mut ansi = color.to_ansi_background();
ansi.foreground(if color.is_light() {
RGBColor::new(0, 0, 0)
} else {
RGBColor::... | code_fim | hard | {
"lang": "rust",
"repo": "L3afMe/colou-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: L3afMe/colou-rs path: /src/main.rs
mod colors;
use std::env;
use colors::ComplementaryColors;
use colors::rgb::RGBColor;
fn main() {
let mut args: Vec<String> = env::args().collect();
args.remove(0);
if args.len() == 0 || args[0].eq("-h") || args[0].eq("--help") {
send_he... | code_fim | hard | {
"lang": "rust",
"repo": "L3afMe/colou-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 0,
// |acc, s: Result<String, std::io::Error>| -> Result<i32, Box<Error>> {
// let s: String = s?;
// let n = s.parse::<i32>()?;
//
// Ok(acc + n)
// },
// );
//
// Ok(println!("{}", sum?))
//}<|fim_prefix|>// repo: herojan/adventofcode2018 pat... | code_fim | medium | {
"lang": "rust",
"repo": "herojan/adventofcode2018",
"path": "/day1/src/initial_attempt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n = s.parse::<i32>()?;
//
// Ok(acc + n)
// },
// );
//
// Ok(println!("{}", sum?))
//}<|fim_prefix|>// repo: herojan/adventofcode2018 path: /day1/src/initial_attempt.rs
//use std::error::Error;
//use std::fs::File;
//use std::io::BufRead;
//use std::io::BufReader;... | code_fim | medium | {
"lang": "rust",
"repo": "herojan/adventofcode2018",
"path": "/day1/src/initial_attempt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: herojan/adventofcode2018 path: /day1/src/initial_attempt.rs
//use std::error::Error;
//use std::fs::File;
//use std::io::BufRead;
//use std::io::BufReader;
//
//
//fn main() -> Result<()<|fim_suffix|> 0,
// |acc, s: Result<String, std::io::Error>| -> Result<i32, Box<Error>> {
// ... | code_fim | medium | {
"lang": "rust",
"repo": "herojan/adventofcode2018",
"path": "/day1/src/initial_attempt.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/macros/macro-backtrace-println.rs
// The `format_args!` syntax extension issues errors before code expansion
// has completed, but we still need a backtrace.
<|fim_suffix|>
macro_rules! myprint {
($($arg:tt)*) => (print(format_args!($($arg)... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/macros/macro-backtrace-println.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! myprintln {
($fmt:expr) => (myprint!(concat!($fmt, "\n"))); //~ ERROR no arguments were given
}
fn main() {
myprintln!("{}");
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/macros/macro-backtrace-println.rs
// The `format_args!` syntax extension issues er... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/macros/macro-backtrace-println.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
macro_rules! myprint {
($($arg:tt)*) => (print(format_args!($($arg)*)));
}
macro_rules! myprintln {
($fmt:expr) => (myprint!(concat!($fmt, "\n"))); //~ ERROR no arguments were given
}
fn main() {
myprintln!("{}");
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/m... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/macros/macro-backtrace-println.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhaoshane/UringForStratoVirt path: /boot_loader/src/lib.rs
// Copyright (c) 2020 Huawei Technologies Co.,Ltd. All rights reserved.
//
// StratoVirt is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan
// PSL v2.
// You may obtain a copy ... | code_fim | hard | {
"lang": "rust",
"repo": "zhaoshane/UringForStratoVirt",
"path": "/boot_loader/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
/// Load PE(vmlinux.bin) linux kernel and other boot source to Guest Memory.
///
/// # Steps
///
/// 1. Prepare for linux kernel boot env, return guest memory layout.
/// 2. According guest memory layout, load PE linux kernel to guest memory.
/// 3. According guest memory layout, load initrd... | code_fim | hard | {
"lang": "rust",
"repo": "zhaoshane/UringForStratoVirt",
"path": "/boot_loader/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut i = (len - 1) as i32;
let mut new_head = None;
while i >= 0 {
let mut node = ListNode::new(arr[i as usize]);
node.next = new_head;
new_head = Some(Box::new(node));
i -= 1;
}
new_head
}
}<|... | code_fim | hard | {
"lang": "rust",
"repo": "arthurDz/algorithm-studies",
"path": "/rust/swapping_nodes_in_a_linked_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arthurDz/algorithm-studies path: /rust/swapping_nodes_in_a_linked_list.rs
impl Solution {
pub fn swap_nodes(head: Option<Box<ListNode>>, k: i32) -> Option<Box<ListNode>> {
let mut arr = Vec::new();
let mut head = head;
<|fim_suffix|> let len = arr.len();
... | code_fim | hard | {
"lang": "rust",
"repo": "arthurDz/algorithm-studies",
"path": "/rust/swapping_nodes_in_a_linked_list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gitter-badger/cargo-compete path: /resources/template-main.rs
use std::io::{self, Read as _};
fn main() {
let mut input = "".to_owned();
io::stdin().read_to_string(&mut input).unwrap();
let mut input = i<|fim_suffix|>
(Bytes) => (read!(String).into_bytes());
($ty:ty)... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/cargo-compete",
"path": "/resources/template-main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
(Bytes) => (read!(String).into_bytes());
($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap());
);
let n = read!(usize);
}<|fim_prefix|>// repo: gitter-badger/cargo-compete path: /resources/template-main.rs
use std::io::{self, Read as _};
fn main() {
let mut input = "... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/cargo-compete",
"path": "/resources/template-main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aeroevan/aoc path: /2018/10/src/main.rs
#[macro_use]
extern crate lazy_static;
extern crate regex;
use regex::Regex;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::iter::FromIterator;
#[derive(Debug, Clone, Copy)]
struct Pixel {
x: i32,
y: i32,
dx: i32,
dy: i32,
... | code_fim | hard | {
"lang": "rust",
"repo": "aeroevan/aoc",
"path": "/2018/10/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let minx: i32 = pixels.iter().map(|p| p.x).min().expect("no min x?");
let maxx: i32 = pixels.iter().map(|p| p.x).max().expect("no max x?");
let miny: i32 = pixels.iter().map(|p| p.y).min().expect("no min y?");
let maxy: i32 = pixels.iter().map(|p| p.y).max().expect("no max y?");
((maxx... | code_fim | hard | {
"lang": "rust",
"repo": "aeroevan/aoc",
"path": "/2018/10/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ScheduleNode {
#[inline(always)]
pub fn free(self) -> () {
unsafe {
let ret = isl_schedule_node_free(self.to());
(ret).to()
}
}
#[inline(always)]
pub fn map_descendant_bottom_up<F1: FnMut(ScheduleNode) -> Option<ScheduleNode>>(self, fn_: &mut F1) -> Option<ScheduleNode> ... | code_fim | hard | {
"lang": "rust",
"repo": "LyricZhao/plant",
"path": "/isl-rs/src/schedule_node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LyricZhao/plant path: /isl-rs/src/schedule_node.rs
ays)]
pub fn map_descendant_bottom_up<F1: FnMut(ScheduleNode) -> Option<ScheduleNode>>(self, fn_: &mut F1) -> Option<ScheduleNode> {
unsafe extern "C" fn fn1<F: FnMut(ScheduleNode) -> Option<ScheduleNode>>(node: ScheduleNode, user: *mut c_... | code_fim | hard | {
"lang": "rust",
"repo": "LyricZhao/plant",
"path": "/isl-rs/src/schedule_node.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ScheduleNodeRef {
#[inline(always)]
pub fn copy(self) -> Option<ScheduleNode> {
unsafe {
let ret = isl_schedule_node_copy(self.to());
(ret).to()
}
}
#[inline(always)]
pub fn is_equal(self, node2: ScheduleNodeRef) -> Bool {
unsafe {
let ret = isl_schedule_node_i... | code_fim | hard | {
"lang": "rust",
"repo": "LyricZhao/plant",
"path": "/isl-rs/src/schedule_node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /sdk/iot_deviceupdate/src/device_update.rs
erde(with = "azure_core::date::rfc3339")]
created_date_time: OffsetDateTime,
description: Option<String>,
etag: String,
friendly_name: Option<String>,
#[serde(with = "azure_core::date::rfc3339")]
im... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/sdk/iot_deviceupdate/src/device_update.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_suffix|> match response.next_link {
None => break,
Some(url) => {
uri = self.device_update_url.clone();
uri.set_path("");
uri.set_query(None);
uri = uri.join(&url).with_context(ErrorKind::Dat... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/sdk/iot_deviceupdate/src/device_update.rs",
"mode": "spm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /sdk/iot_deviceupdate/src/device_update.rs
steps: Vec<Step>,
}
#[derive(Debug, Deserialize, Getters)]
#[getset(get = "pub")]
#[serde(rename_all = "camelCase")]
pub struct Update {
compatibility: Vec<Map<String, Value>>,
#[serde(with = "azure_core::date::r... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/sdk/iot_deviceupdate/src/device_update.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yourkeychen/filecoin-bridge path: /bridge/api/src/api/client.rs
use super::JsonApi;
use crate::error::Result;
use crate::helper;
use crate::types::{Cid, CidJson, CidJsonRef, StartDealParams, DealInfo, QueryOffer, RetrievalOrder, PeerId,
Address, PeerIdRefWrapper, CommPRet, Import, FileRef};
///... | code_fim | hard | {
"lang": "rust",
"repo": "yourkeychen/filecoin-bridge",
"path": "/bridge/api/src/api/client.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn client_calc_comm_p(&self, inpath: &str, miner: &Address) -> Result<CommPRet> {
self.request(
"ClientCalcCommP",
vec![helper::serialize(&inpath), helper::serialize(miner)],
)
.await
}
async fn client_gen_car(&self, r#ref: &FileRef, o... | code_fim | hard | {
"lang": "rust",
"repo": "yourkeychen/filecoin-bridge",
"path": "/bridge/api/src/api/client.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl_morton!(u32 => u64 [0x55555555_55555555, 0xAAAAAAAA_AAAAAAAA]);
impl_morton!(u16 => u32 [0x55555555, 0xAAAAAAAA]);
impl_morton!(u8 => u16 [0x5555, 0xAAAA]);
impl_morton!(i32 => i64 [0x55555555_55555555, -0x55555555_55555556]);
impl_morton!(i16 => i32 [0x55555555, -0x55555556]);
impl_morton!(i8 => i1... | code_fim | hard | {
"lang": "rust",
"repo": "TehPers/BevyGame",
"path": "/engine/crates/game_morton/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x = z.pext($x_mask) as Self;
let y = z.pext($y_mask) as Self;
(x, y)
}
}
};
}
impl_morton!(u32 => u64 [0x55555555_55555555, 0xAAAAAAAA_AAAAAAAA]);
impl_morton!(u16 => u32 [0x55555555, 0xAAAAAAAA]);
impl_morton!(u8 => u16 [0x5555,... | code_fim | hard | {
"lang": "rust",
"repo": "TehPers/BevyGame",
"path": "/engine/crates/game_morton/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TehPers/BevyGame path: /engine/crates/game_morton/src/lib.rs
use bitintr::{Pdep, Pext};
/// Provides functions for encoding/decoding coordinates using Morton z-curve encoding.
/// This encoding attempts to ensure that spatial proximity translates to proximity
/// within memory when stored in a ... | code_fim | hard | {
"lang": "rust",
"repo": "TehPers/BevyGame",
"path": "/engine/crates/game_morton/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zachs18/advent-of-code-2020 path: /rust/day_17/part2.rs
use std::collections::{HashSet, HashMap};
use std::ops::RangeInclusive;
use std::io;
pub struct Space {
active: HashSet<(i32, i32, i32, i32)>,
}
impl Space {
pub fn new(initial: HashSet<(i32, i32, i32, i32)>) -> Self {
Sel... | code_fim | hard | {
"lang": "rust",
"repo": "zachs18/advent-of-code-2020",
"path": "/rust/day_17/part2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ( 0, 1, -1, -1),
( 0, 1, -1, 0),
( 0, 1, -1, 1),
( 0, 1, 0, -1),
( 0, 1, 0, 0),
( 0, 1, 0, 1),
( 0, 1, 1, -1),
... | code_fim | hard | {
"lang": "rust",
"repo": "zachs18/advent-of-code-2020",
"path": "/rust/day_17/part2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wonderful-panda/inazuma path: /src-tauri/app/src/main.rs
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
<|fim_suffix|>#[tokio::main]
async fn main() {
env_logger::init();
app::run()
}<|fim_middle|>extern crate env_logger;
extern ... | code_fim | easy | {
"lang": "rust",
"repo": "wonderful-panda/inazuma",
"path": "/src-tauri/app/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::main]
async fn main() {
env_logger::init();
app::run()
}<|fim_prefix|>// repo: wonderful-panda/inazuma path: /src-tauri/app/src/main.rs
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
<|fim_middle|>extern crate env_logger;
extern ... | code_fim | easy | {
"lang": "rust",
"repo": "wonderful-panda/inazuma",
"path": "/src-tauri/app/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_links() -> Result<Vec<String>, io::Error> {
let link_responses = netlink_call(
RtnlMessage::GetLink(LinkMessage::default()),
Some(NLM_F_DUMP | NLM_F_REQUEST),
)?;
let links = link_responses
.into_iter()
// Filter out non-link messages
.filter_map(... | code_fim | hard | {
"lang": "rust",
"repo": "tianon/innernet",
"path": "/shared/src/netlink.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tianon/innernet path: /shared/src/netlink.rs
use ipnetwork::IpNetwork;
use netlink_packet_core::{
NetlinkMessage, NetlinkPayload, NLM_F_ACK, NLM_F_CREATE, NLM_F_EXCL, NLM_F_REQUEST,
};
use netlink_packet_route::{
address,
constants::*,
link::{self, nlas::State},
route, Addres... | code_fim | hard | {
"lang": "rust",
"repo": "tianon/innernet",
"path": "/shared/src/netlink.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(links)
}
pub fn get_local_addrs() -> Result<impl Iterator<Item = IpAddr>, io::Error> {
let links = get_links()?;
let addr_responses = netlink_call(
RtnlMessage::GetAddress(AddressMessage::default()),
Some(NLM_F_DUMP | NLM_F_REQUEST),
)?;
let addrs = addr_responses
... | code_fim | hard | {
"lang": "rust",
"repo": "tianon/innernet",
"path": "/shared/src/netlink.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sameer/eink-clock path: /src/network.rs
use futures::stream::TryStreamExt;
use ipnetwork::IpNetwork;
use netlink_packet_route::rtnl::AddressMessage;
use rtnetlink::{Error, Handle};
use crate::{KINDLE_INTERFACE, PI_IP_ADDRESS};
pub async fn setup_if_down(handle: &Handle) -> Result<(), Error> {
... | code_fim | hard | {
"lang": "rust",
"repo": "sameer/eink-clock",
"path": "/src/network.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn get_address(handle: &Handle, ip: IpNetwork) -> Result<Option<AddressMessage>, Error> {
handle
.address()
.get()
.set_address_filter(ip.ip())
.set_prefix_length_filter(ip.prefix())
.execute()
.try_next()
.await
}
async fn link_down(handl... | code_fim | hard | {
"lang": "rust",
"repo": "sameer/eink-clock",
"path": "/src/network.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dgreid/crosvm path: /vhost/src/vsock.rs
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use std::fs::File;
use base::{ioctl_with_ref, AsRawDescriptor, RawDescriptor};
use vir... | code_fim | hard | {
"lang": "rust",
"repo": "dgreid/crosvm",
"path": "/vhost/src/vsock.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if ret < 0 {
return ioctl_result();
}
Ok(())
}
}
impl Vhost for Vsock {}
impl AsRawDescriptor for Vsock {
fn as_raw_descriptor(&self) -> RawDescriptor {
self.descriptor.as_raw_descriptor()
}
}<|fim_prefix|>// repo: dgreid/crosvm path: /vhost/src/v... | code_fim | hard | {
"lang": "rust",
"repo": "dgreid/crosvm",
"path": "/vhost/src/vsock.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Tell the VHOST driver to stop performing data transfer.
pub fn stop(&self) -> Result<()> {
self.set_running(false)
}
fn set_running(&self, running: bool) -> Result<()> {
let on: ::std::os::raw::c_int = if running { 1 } else { 0 };
let ret = unsafe { ioctl_with_... | code_fim | hard | {
"lang": "rust",
"repo": "dgreid/crosvm",
"path": "/vhost/src/vsock.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ksqsf/toys path: /websocketd/src/frames.rs
//! # Frame encoding and decoding
//!
//! WebSocket is "almost" raw TCP connection, except that it
//! introduces its own frame type.
//!
//! This module provides several types and enums to work with
//! WebSocket frames, and implements frame encoding a... | code_fim | hard | {
"lang": "rust",
"repo": "ksqsf/toys",
"path": "/websocketd/src/frames.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mask_key = {
if self.has_mask {
[src[header_len as usize - 4],
src[header_len as usize - 3],
src[header_len as usize - 2],
src[header_len as usize - 1]]
} else {
[0; 4]
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ksqsf/toys",
"path": "/websocketd/src/frames.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yamakii/think_like_a_programmer_in_rust path: /pointer/src/main.rs
#![allow(dead_code)]
fn main() {
println!("hello");
}
mod array_string {
type ArrayString = Box<[char]>;
fn charactor_at(array_string: &ArrayString, position: usize) -> char {
array_string[position]
}
... | code_fim | hard | {
"lang": "rust",
"repo": "yamakii/think_like_a_programmer_in_rust",
"path": "/pointer/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn add_record(student_collection: &mut StudentCollection, number: u32, grade: u32) {
if let Some(current) = student_collection.take() {
let head = StudentNode {
number,
grade,
next: Some(Box::new(current)),
};
... | code_fim | hard | {
"lang": "rust",
"repo": "yamakii/think_like_a_programmer_in_rust",
"path": "/pointer/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(test)]
mod tests {
use super::*;
fn make_data() -> StudentCollection {
let mut node1 = StudentNode {
number: 1001,
grade: 78,
next: None,
};
let mut node2 = StudentNode {
numbe... | code_fim | hard | {
"lang": "rust",
"repo": "yamakii/think_like_a_programmer_in_rust",
"path": "/pointer/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let self_ = imp::ExampleApplicationWindow::from_instance(self);
let width = self_.settings.int("window-width");
let height = self_.settings.int("window-height");
let is_maximized = self_.settings.boolean("is-maximized");
self.set_default_size(width, height);
... | code_fim | hard | {
"lang": "rust",
"repo": "bonedaddy/gtk-rust-template",
"path": "/src/window.rs",
"mode": "spm",
"license": "X11",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bonedaddy/gtk-rust-template path: /src/window.rs
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{gio, glib};
use crate::application::ExampleApplication;
use crate::config::{APP_ID, PROFILE};
mod imp {
use super::*;
use gtk::CompositeTemplate;
#[derive(Debug, Composi... | code_fim | hard | {
"lang": "rust",
"repo": "bonedaddy/gtk-rust-template",
"path": "/src/window.rs",
"mode": "psm",
"license": "X11",
"source": "the-stack-v2"
} |
<|fim_suffix|> _ => {
Err(AssemblerError::ExpressionError(ExpressionError::OwnError(
Box::new(AssemblerError::AssemblingError {
msg: format!("{} is not a matrix", matrix)
})
)))
}
}
}
pub fn matrix_width(matrix: &ExprResult)... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-asm/src/assembler/matrix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpcsdk/rust.cpclib path: /cpclib-asm/src/assembler/matrix.rs
use cpclib_tokens::ExprResult;
use crate::assembler::list::list_new;
use crate::error::{AssemblerError, ExpressionError};
/// Create a new matrix
pub fn matrix_new(height: usize, width: usize, value: ExprResult) -> ExprResult {
E... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-asm/src/assembler/matrix.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the status code of the response.
pub fn status_code(&self) -> u16 {
self.0.status_code().as_u16()
}
/// Returns the header of the response.
pub fn header(&self) -> Header {
self.0.header()
}
/// Returns the mutable header of the response.
pub f... | code_fim | hard | {
"lang": "rust",
"repo": "koba-e964/fibers_http_server",
"path": "/src/response.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: koba-e964/fibers_http_server path: /src/response.rs
use crate::header;
use crate::status::Status;
use bytecodec::bytes::Utf8Encoder;
use bytecodec::marker::Never;
use bytecodec::{self, ByteCount, Encode, EncodeExt, Eos};
use httpcodec::{
BodyEncoder, Header, HeaderMut, HttpVersion, ReasonPhr... | code_fim | hard | {
"lang": "rust",
"repo": "koba-e964/fibers_http_server",
"path": "/src/response.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn error(status: Status) -> Self {
let mut res = Res::new(status, status.reason_phrase());
res.header_mut().add_field(header::Connection::Close);
let encoder = ResponseEncoder::new(BodyEncoder::new(Utf8Encoder::new()));
ResEncoder(Box::new(encoder.last(res.0)))
... | code_fim | hard | {
"lang": "rust",
"repo": "koba-e964/fibers_http_server",
"path": "/src/response.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
macro_rules! impl_is_minus_one {
($($t:ident)*) => ($(impl IsMinusOne for $t {
fn is_minus_one(&self) -> bool {
*self == -1
}
})*)
}
impl_is_minus_one! { i8 i16 i32 i64 isize }
pub fn cvt<T: IsMinusOne>(t: T) -> crate::io::Result<T> {
if t.is_minus_one() {
... | code_fim | hard | {
"lang": "rust",
"repo": "jstarry/rust-bpf-sysroot",
"path": "/src/libstd/sys/wasi/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jstarry/rust-bpf-sysroot path: /src/libstd/sys/wasi/mod.rs
//! System bindings for the wasm/web platform
//!
//! This module contains the facade (aka platform-specific) implementations of
//! OS level functionality for wasm. Note that this wasm is *not* the emscripten
//! wasm, so we have no run... | code_fim | hard | {
"lang": "rust",
"repo": "jstarry/rust-bpf-sysroot",
"path": "/src/libstd/sys/wasi/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn hashmap_random_keys() -> (u64, u64) {
let mut ret = (0u64, 0u64);
unsafe {
let base = &mut ret as *mut (u64, u64) as *mut libc::c_void;
let len = mem::size_of_val(&ret);
cvt_wasi(libc::__wasi_random_get(base, len)).unwrap();
}
return ret
}
#[doc(hidden)]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "jstarry/rust-bpf-sysroot",
"path": "/src/libstd/sys/wasi/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>use {queries::NexmarkInput, queries::NexmarkTimer};
pub fn q6_flex<S: Scope<Timestamp=usize>>(input: &NexmarkInput, _nt: NexmarkTimer, scope: &mut S) -> Stream<S, (usize, usize)>
{
let control = input.control(scope);
let winners = input.closed_auctions_flex(scope)
.map(|(_a, b)| (b.bidder... | code_fim | medium | {
"lang": "rust",
"repo": "strymon-system/megaphone",
"path": "/nexmark/src/queries/q6_flex.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: strymon-system/megaphone path: /nexmark/src/queries/q6_flex.rs
use ::std::collections::HashMap;
use ::timely::dataflow::{Scope, Stream};
use timely::dataflow::operators::Map;
use dynamic_scaling_mechanism::operator::StatefulOperator;
use ::calculate_hash;
<|fim_suffix|>pub fn q6_flex<S: Scope... | code_fim | medium | {
"lang": "rust",
"repo": "strymon-system/megaphone",
"path": "/nexmark/src/queries/q6_flex.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> winners.stateful_unary(&control, |(b, _p)| calculate_hash(b), "q6-flex", |cap, data, bin, output| {
let mut session = output.session(&cap);
let state: &mut HashMap<_, _> = bin.state();
for (_time, (bidder, price)) in data.drain(..) {
let entry = state.entry(bidder).... | code_fim | hard | {
"lang": "rust",
"repo": "strymon-system/megaphone",
"path": "/nexmark/src/queries/q6_flex.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.