text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> // if we see "default\n\techo fail" in `justfile` then we're running
// in a case insensitive filesystem, so just bail
path.push("justfile");
if brev::slurp(&path) == "default:\n\techo fail" {
return;
}
path.pop();
path.push("a");
fs::create_dir(&path).expect("test justfile search: fa... | code_fim | hard | {
"lang": "rust",
"repo": "peterkinalex/just",
"path": "/tests/search.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Evaluate filter
fn eval(&self, input: &[&Image<T, C>], output: &mut Image<U, D>) {
let input = Input::new(input);
output.for_each(|pt, mut data| {
self.compute_at(pt, &input, &mut data);
});
}
/// Evaluate filter using the same image for input and ... | code_fim | hard | {
"lang": "rust",
"repo": "zshipko/image2-rs",
"path": "/src/filters/mod.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Evaluate a filter on part of an image
fn eval_partial(&self, roi: Region, input: &[&Image<T, C>], output: &mut Image<U, D>) {
let input = Input::new(input);
let iter = output.iter_region_mut(roi);
iter.for_each(|(pt, mut data)| {
self.compute_at(pt, &input,... | code_fim | hard | {
"lang": "rust",
"repo": "zshipko/image2-rs",
"path": "/src/filters/mod.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zshipko/image2-rs path: /src/filters/mod.rs
use crate::*;
#[cfg(feature = "parallel")]
use rayon::prelude::*;
mod r#async;
mod ext;
mod input;
mod pipeline;
/// Image processing filters
pub mod filter;
pub use ext::*;
pub use input::Input;
pub use pipeline::*;
pub use r#async::*;
/// Filter... | code_fim | hard | {
"lang": "rust",
"repo": "zshipko/image2-rs",
"path": "/src/filters/mod.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 1..self.map.len() {
self.move_to(*move_x, *move_y);
}
}
fn move_to(&mut self, move_x: HorizontalMove, move_y: VerticalMove) {
let (dest_y, dest_x) = self.parse_moves(move_x, move_y);
if dest_y >= self.map.len() {
return;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "douglascamata/aoc_2020",
"path": "/rust/day3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let moves: Vec<(HorizontalMove, VerticalMove, usize)> = vec![
(HorizontalMove::Right(1), VerticalMove::Down(1), 2),
(HorizontalMove::Right(3), VerticalMove::Down(1), 7),
(HorizontalMove::Right(5), VerticalMove::Down(1), 3),
(HorizontalMove::Right(7), VerticalMove::Down(... | code_fim | hard | {
"lang": "rust",
"repo": "douglascamata/aoc_2020",
"path": "/rust/day3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: douglascamata/aoc_2020 path: /rust/day3/src/main.rs
use std::fs::read_to_string;
use std::ops::{Index, IndexMut};
#[derive(Debug)]
struct RingBuffer<T> {
array: Vec<T>,
}
impl RingBuffer<char> {
fn from_string(input: &str) -> Self {
let input_list: Vec<char> = input.chars().col... | code_fim | hard | {
"lang": "rust",
"repo": "douglascamata/aoc_2020",
"path": "/rust/day3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loewenheim/pueue path: /daemon/task_handler/messages/pause.rs
use log::{error, info};
use pueue_lib::network::message::TaskSelection;
use pueue_lib::state::GroupStatus;
use pueue_lib::task::TaskStatus;
use crate::ok_or_shutdown;
use crate::state_helper::{save_state, LockedState};
use crate::ta... | code_fim | hard | {
"lang": "rust",
"repo": "loewenheim/pueue",
"path": "/daemon/task_handler/messages/pause.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.perform_action(id, ProcessAction::Pause, pause_children) {
Err(err) => error!("Failed pausing task {}: {:?}", id, err),
Ok(success) => {
if success {
state.change_status(id, TaskStatus::Paused);
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "loewenheim/pueue",
"path": "/daemon/task_handler/messages/pause.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn is_full(&self) -> bool {
match *self {
TwoColorsBuf::Two(_, _) => true,
_ => false,
}
}
}
pub trait ColorFormat: Sized {
/// How many bytes to write at once
type Buf: ColorBuf<Self>;
/// COLMOD Register value
fn colmod() -> u8;
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "astro/rad1o-rust",
"path": "/rad1o-firmware/src/lcd/pcf8833.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Write color data
fn write<F>(colors: Self::Buf, f: F)
where F: FnMut(u8),
Self: Sized;
}
#[derive(Clone)]
pub struct RGB12 {
pub r: u8,
pub g: u8,
pub b: u8,
}
impl ColorFormat for RGB12 {
type Buf = TwoColorsBuf<Self>;
fn colmod() -> u8 {
3... | code_fim | hard | {
"lang": "rust",
"repo": "astro/rad1o-rust",
"path": "/rad1o-firmware/src/lcd/pcf8833.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astro/rad1o-rust path: /rad1o-firmware/src/lcd/pcf8833.rs
use core::mem::replace;
use embedded_hal::digital::OutputPin;
use embedded_hal::blocking::spi::{Transfer, Write};
pub const RESX: usize = 130;
pub const RESY: usize = 130;
const SSP_DATA_9BITS: u8 = 0x8;
const SSP_FRAME_SPI: u8 = 0x00;
... | code_fim | hard | {
"lang": "rust",
"repo": "astro/rad1o-rust",
"path": "/rad1o-firmware/src/lcd/pcf8833.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let contents = fs::read_to_string(filename).expect("Error reading file");
let stmts = instant_parser::StmtsParser::new().parse(&contents).unwrap();
let code = llvm::compile(&stmts);
let path = Path::new(filename);
let file_stem = path.file_stem().expect("Unable to get file stem").to... | code_fim | hard | {
"lang": "rust",
"repo": "kkragoth-mimuw/instant",
"path": "/src/insc_llvm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kkragoth-mimuw/instant path: /src/insc_llvm.rs
use std::env;
use std::fs;
use std::path::Path;
use std::process::Command;
pub mod ast;
pub mod instant_parser;
pub mod llvm;
/*
tests=(01 02 03 04 05 06 07)
for x in ${tests[*]}; do
./insc_llvm foo/bar/test$x.ins
done
cd foo/bar;
for x in ... | code_fim | hard | {
"lang": "rust",
"repo": "kkragoth-mimuw/instant",
"path": "/src/insc_llvm.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Command::new("llvm-as")
.args(&["-o", &generated_intermediate_bc_path, &generated_code_path])
.output()
.expect("failed to execute llvm-as");
Command::new("llvm-link")
.args(&["-o", &generated_linked_bc_path, &generated_intermediate_bc_path, "lib/runtime.bc"])
... | code_fim | hard | {
"lang": "rust",
"repo": "kkragoth-mimuw/instant",
"path": "/src/insc_llvm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fruit-in/exercism-solution path: /rust/tournament/src/lib.rs
use std::collections::HashMap;
pub fn tally(match_results: &str) -> String {
let mut hash = HashMap::new();
let mut table = vec!["Team | MP | W | D | L | P".to_string()];
<|fim_suffix|> let mu... | code_fim | hard | {
"lang": "rust",
"repo": "fruit-in/exercism-solution",
"path": "/rust/tournament/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (name, result) in teams {
table.push(format!(
"{:<30} | {:>2} | {:>2} | {:>2} | {:>2} | {:>2}",
name,
result[0],
result[1],
result[2],
result[3],
result[1] * 3 + result[2]
));
}
table.join(... | code_fim | hard | {
"lang": "rust",
"repo": "fruit-in/exercism-solution",
"path": "/rust/tournament/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ref rec) = recurse {
rec.print();
}
Ok(())
}
#[derive(Copy, Clone)]
enum Display {
Normal,
Long,
}
struct NormalPrinter {
display: Display,
prefix_len: usize,
}
fn print_dir(display: Display, dir: &str) {
match display {
Display::Normal => pr... | code_fim | hard | {
"lang": "rust",
"repo": "DeanBDean/gsutil",
"path": "/src/ls.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DeanBDean/gsutil path: /src/ls.rs
use crate::util;
use ansi_term::Color;
use anyhow::Error;
use structopt::StructOpt;
use tame_gcs::{
common::StandardQueryParameters,
objects::{ListOptional, ListResponse, Metadata, Object},
};
#[derive(StructOpt, Debug)]
pub struct Args {
/// Recurs... | code_fim | hard | {
"lang": "rust",
"repo": "DeanBDean/gsutil",
"path": "/src/ls.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fields = match display {
Display::Normal => "items(name), prefixes, nextPageToken",
Display::Long => "items(name, updated, size), prefixes, nextPageToken",
};
let mut page_token: Option<String> = None;
loop {
let ls_req = Object::list(
oid.bucket(),... | code_fim | hard | {
"lang": "rust",
"repo": "DeanBDean/gsutil",
"path": "/src/ls.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> TargetPoint::new(
self.temperature_noise.sample(xx, 0.0, zz),
self.humidity_noise.sample(xx, 0.0, zz),
self.continentalness_noise.sample(xx, 0.0, zz),
self.erosion_noise.sample(xx, 0.0, zz),
self.weirdness_noise.sample(xx, 0.0, zz),
0.0, // depth is set to 0 until terrainshaper is impl... | code_fim | hard | {
"lang": "rust",
"repo": "misode/deepslate-rs",
"path": "/src/sampler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: misode/deepslate-rs path: /src/sampler.rs
use wasm_bindgen::prelude::*;
use super::random::{ LegacyRandomSource as Random };
use super::noise::{ NormalNoise, NoiseParameters };
use super::climate::{ TargetPoint };
#[wasm_bindgen]
pub struct NoiseOctaves {
temperature: NoiseParameters,
humidit... | code_fim | hard | {
"lang": "rust",
"repo": "misode/deepslate-rs",
"path": "/src/sampler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sonos/tract path: /test-rt/test-onnx-nnef-cycle/src/lib.rs
#![cfg(test)]
use log::*;
use tract_nnef::internal::*;
use tract_onnx_opl::*;
struct NnefCyclingRuntime(Nnef);
<|fim_suffix|> "nnef_cycle".into()
}
fn prepare(&self, model: TypedModel) -> TractResult<Box<dyn Runnable>> ... | code_fim | medium | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/test-rt/test-onnx-nnef-cycle/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> info!("Store to NNEF");
let mut buffer = vec![];
self.0.write_to_tar(&model, &mut buffer)?;
info!("Reload from NNEF");
let reloaded = self.0.model_for_read(&mut &*buffer)?;
Ok(Box::new(Arc::new(reloaded.into_optimized()?.into_runnable()?)))
}
}
fn nnef_... | code_fim | medium | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/test-rt/test-onnx-nnef-cycle/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustyscreeps/rusty-screeps path: /src/data/spawn.rs
use crate::data::Job;
use core::borrow::Borrow;
use screeps::{
CanStoreEnergy, HasPosition, Part, ReturnCode, Room, RoomName, RoomObjectProperties,
RoomPosition,
};
pub struct Spawn {
_source: screeps::StructureSpawn,
name: Str... | code_fim | hard | {
"lang": "rust",
"repo": "rustyscreeps/rusty-screeps",
"path": "/src/data/spawn.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn energy_capacity(&self) -> u32 {
self._source.energy_capacity()
}
pub fn spawn_job_creep(&self, body: &[Part], job: Job) -> ReturnCode {
let name = screeps::game::time();
let mut additional = 0;
loop {
let name = format!("{}:{}{}", job.as_str(... | code_fim | hard | {
"lang": "rust",
"repo": "rustyscreeps/rusty-screeps",
"path": "/src/data/spawn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = self.buffer.write();
if buffer.len() <= end {
return Err(Error::Memory(format!("trying to update region [{}..{}] in memory [0..{}]", begin, end, buffer.len())));
}
let mut mut_buffer = buffer.as_mut_slice();
mut_buffer[begin..end].copy_from_slice(value);
Ok(())
}
/// I... | code_fim | hard | {
"lang": "rust",
"repo": "rphmeier/parity-wasm",
"path": "/src/interpreter/memory.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rphmeier/parity-wasm path: /src/interpreter/memory.rs
use std::u32;
use std::sync::Arc;
use parking_lot::RwLock;
use elements::MemoryType;
use interpreter::Error;
/// Linear memory page size.
pub const LINEAR_MEMORY_PAGE_SIZE: u32 = 65536;
/// Linear memory instance.
pub struct MemoryInstance ... | code_fim | hard | {
"lang": "rust",
"repo": "rphmeier/parity-wasm",
"path": "/src/interpreter/memory.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Increases the size of the linear memory by given number of pages.
/// Returns -1 if allocation fails or previous memory size, if succeeds.
pub fn grow(&self, pages: u32) -> Result<u32, Error> {
let mut buffer = self.buffer.write();
let old_size = buffer.len() as u32;
match pages.checked_mul(L... | code_fim | hard | {
"lang": "rust",
"repo": "rphmeier/parity-wasm",
"path": "/src/interpreter/memory.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tlent/advent-of-code path: /year_2022/day_16/src/main.rs
use day_16::{self, INPUT};
use std::env;
fn main() {
let parse_result = day_16::parser::parse(INPUT).unwrap();
match env::args().nth(1).as_deref() {
Some("all") => {
let (processed_valves, initial_distances) = ... | code_fim | hard | {
"lang": "rust",
"repo": "tlent/advent-of-code",
"path": "/year_2022/day_16/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (processed_valves, initial_distances) = day_16::preprocess(parse_result);
let part_two = day_16::part_two(&processed_valves, &initial_distances);
println!("{part_two}");
}
_ => println!("Invalid argument: must be one of all, parse, one, or two"),
}
}<... | code_fim | hard | {
"lang": "rust",
"repo": "tlent/advent-of-code",
"path": "/year_2022/day_16/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub block_0: Block0Info,
pub leadership: Option<PathBuf>,
pub log_settings: LogSettings,
pub rest: Option<Rest>,
}
impl Settings {
/// Load the settings
/// - from the command arguments
/// - from the config
///
/// This function will print&exit if anything is not a... | code_fim | hard | {
"lang": "rust",
"repo": "SViksha/jormungandr",
"path": "/src/settings/start/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SViksha/jormungandr path: /src/settings/start/mod.rs
mod config;
pub mod network;
use self::config::ConfigLogSettings;
pub use self::config::Rest;
use self::network::Protocol;
use crate::rest::Error as RestError;
use crate::settings::logging::LogSettings;
use crate::settings::{command_arguments... | code_fim | hard | {
"lang": "rust",
"repo": "SViksha/jormungandr",
"path": "/src/settings/start/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oknozor/musicbrainz_rs path: /src/deserialization/browse_deserializer.rs
use crate::entity::Browsable;
use crate::entity::BrowseResult;
use serde::de::DeserializeOwned;
use std::fmt;
use std::marker::PhantomData;
use serde::de::{self, Deserialize, Deserializer, MapAccess, SeqAccess, Visitor};
... | code_fim | hard | {
"lang": "rust",
"repo": "oknozor/musicbrainz_rs",
"path": "/src/deserialization/browse_deserializer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
T: Browsable + Deserialize<'de>,
V: MapAccess<'de>,
{
let mut count: Option<i32> = None;
let mut offset: Option<i32> = None;
let mut entities: Option<Vec<T>> = None;
while let Some... | code_fim | hard | {
"lang": "rust",
"repo": "oknozor/musicbrainz_rs",
"path": "/src/deserialization/browse_deserializer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jkristell/infrared path: /examples/bluepill/src/bin/tutorial1b.rs
#![no_std]
#![no_main]
use bluepill_examples as _;
use cortex_m_rt::entry;
use defmt::info;
use infrared::{
protocol::{rc6::Rc6Command, Rc6},
remotecontrol::{Action, Button, DeviceType, RemoteControlModel},
ProtocolId... | code_fim | hard | {
"lang": "rust",
"repo": "jkristell/infrared",
"path": "/examples/bluepill/src/bin/tutorial1b.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(Some(cmd)) = receiver.poll() {
use Action::*;
match cmd.action() {
Some(Teletext) => info!("Teletext!"),
Some(Power) => info!("Power on/off"),
_ => info!("cmd: {:?}", cmd),
};
}
// Clear the interrupt
let timer = unsaf... | code_fim | hard | {
"lang": "rust",
"repo": "jkristell/infrared",
"path": "/examples/bluepill/src/bin/tutorial1b.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jfrimmel/cargo-valgrind path: /src/valgrind/xml/tests.rs
use super::{Error, Frame, Kind, Output, Resources};
use std::{fs, io::BufReader};
use serde_xml_rs::{from_reader, from_str};
#[test]
fn sample_output() {
let xml: Output = from_reader(BufReader::new(
fs::File::open("src/valgr... | code_fim | hard | {
"lang": "rust",
"repo": "jfrimmel/cargo-valgrind",
"path": "/src/valgrind/xml/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn invalid_hex_digits_are_an_error() {
let result: Result<Error, _> = from_str(
r"<error>\
<unique>0xhello</unique>\
<tid>1</tid>\
<kind>Leak_DefinitelyLost</kind>\
<xwhat>\
<text>...</text>\
<leakedbytes>15</leakedbyt... | code_fim | hard | {
"lang": "rust",
"repo": "jfrimmel/cargo-valgrind",
"path": "/src/valgrind/xml/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result: Error = from_str(
r"<error>\
<unique>0XdEaDbEeF</unique>\
<tid>1</tid>\
<kind>Leak_DefinitelyLost</kind>\
<xwhat>\
<text>...</text>\
<leakedbytes>15</leakedbytes>\
<leakedblocks>1</leakedblocks>\
... | code_fim | hard | {
"lang": "rust",
"repo": "jfrimmel/cargo-valgrind",
"path": "/src/valgrind/xml/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if evt.ended {
if let Some(mut handler) = guard.remove(&evt.monitor_id) {
while let Some(e) = evt.events.pop() {
handler.send(Ok(e)).await?;
}
drop(handler);
}
} else {
if let Some(handl... | code_fim | hard | {
"lang": "rust",
"repo": "wolf4ood/orientdb-rs",
"path": "/orientdb-client/src/asynchronous/live.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wolf4ood/orientdb-rs path: /orientdb-client/src/asynchronous/live.rs
use super::network::cluster::Server;
#[cfg(feature = "async-std-runtime")]
mod async_std_use {
pub use async_std::sync::Mutex;
}
#[cfg(feature = "async-std-runtime")]
use async_std_use::*;
#[cfg(feature = "tokio-runtime")... | code_fim | hard | {
"lang": "rust",
"repo": "wolf4ood/orientdb-rs",
"path": "/orientdb-client/src/asynchronous/live.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> conn.send_and_forget(
UnsubscribeLiveQuery::new(self.session_id, self.token, self.monitor_id).into(),
)
.await?;
Ok(())
}
}
pub struct LiveQueryManager {
live_queries: Mutex<HashMap<i32, Sender<OrientResult<LiveResult>>>>,
}
impl LiveQueryManager {
... | code_fim | hard | {
"lang": "rust",
"repo": "wolf4ood/orientdb-rs",
"path": "/orientdb-client/src/asynchronous/live.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "complex-expressions")]
#[test]
fn from_primitive_number_with_inclusive_range() {
#[derive(Debug, Eq, PartialEq, FromPrimitive)]
#[repr(u8)]
enum Enum {
Zero = 0,
#[num_enum(alternatives = [2..=255])]
NonZero,
}
let zero = Enum::from_primitive(0... | code_fim | hard | {
"lang": "rust",
"repo": "illicitonion/num_enum",
"path": "/num_enum/tests/from_primitive.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: illicitonion/num_enum path: /num_enum/tests/from_primitive.rs
use ::num_enum::FromPrimitive;
// Guard against https://github.com/illicitonion/num_enum/issues/27
mod alloc {}
mod core {}
mod num_enum {}
mod std {}
macro_rules! has_from_primitive_number {
( $type:ty ) => {
paste::pas... | code_fim | hard | {
"lang": "rust",
"repo": "illicitonion/num_enum",
"path": "/num_enum/tests/from_primitive.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stlankes/uhyve path: /src/paging.rs
// This is a heavily stripped down and slightly modified version of the libhermit-rs x86-64 paging code written by Colin Finck
#![allow(dead_code)]
/// Number of Offset bits of a virtual address for a 4 KiB page, which are shifted away to get its Page Frame ... | code_fim | hard | {
"lang": "rust",
"repo": "stlankes/uhyve",
"path": "/src/paging.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set if Write-Through caching shall be enabled for memory referenced by this entry.
/// Otherwise, Write-Back caching is used.
const WRITE_THROUGH = 1 << 3;
/// Set if caching shall be disabled for memory referenced by this entry.
const CACHE_DISABLE = 1 << 4;
/// Set if software has acce... | code_fim | hard | {
"lang": "rust",
"repo": "stlankes/uhyve",
"path": "/src/paging.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (holded, amount) in bag.iter() {
bag_capacity += match memoized.get(holded) {
Some(value) => amount * (value + 1),
None => {
let value = deep_bag_search(holded.clone(), bags, memoized);
memoized.insert(holded.clone(), value);
... | code_fim | hard | {
"lang": "rust",
"repo": "filippixavier/AoC2020",
"path": "/src/days/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filippixavier/AoC2020 path: /src/days/day7.rs
use regex::Regex;
use std::collections::*;
use std::error::Error;
use std::fs;
use std::path::Path;
type Bags = HashMap<String, HashMap<String, usize>>;
fn prepare_input(input: String) -> Bags {
let holded_bags_reg = Regex::new(r"(\d) ((?:\w|\s... | code_fim | hard | {
"lang": "rust",
"repo": "filippixavier/AoC2020",
"path": "/src/days/day7.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (holder, holdee) in bags.iter() {
if holdee.contains_key(&goal) {
bag_to_check.push(holder.clone());
}
}
}
println!(
"I can fit my beautiful shiny gold bag into {} bags",
recorded_bags.len() - 1
);
Ok(())
}
fn d... | code_fim | hard | {
"lang": "rust",
"repo": "filippixavier/AoC2020",
"path": "/src/days/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZVNexus/fuchsia path: /garnet/bin/odu/src/operations.rs
// Copyright 2019 The Fuchsia 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 {
crate::io_packet::{IoPacket, IoPacketType},
serde_derive::{De... | code_fim | hard | {
"lang": "rust",
"repo": "ZVNexus/fuchsia",
"path": "/garnet/bin/odu/src/operations.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn enabled_none_enabled() {
let x: TargetOps = TargetOps { write: false, open: false };
assert!(!x.enabled("write"));
assert!(!x.enabled("open"));
}
#[test]
fn enable_toggle_one() {
let mut x: TargetOps = TargetOps { write: false, open: false };... | code_fim | hard | {
"lang": "rust",
"repo": "ZVNexus/fuchsia",
"path": "/garnet/bin/odu/src/operations.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhanif3/701 path: /src/bin/bwt_rosalind.rs
#[macro_use]
//extern crate bincode;
extern crate common;
//use serde::{Serialize, Deserialize};
//use std::io::BufWriter;
use std::io;
use std::io::Read;
use std::fs::File;
use std::io::prelude::*;
use std::iter::repeat;
use std::collections::HashMa... | code_fim | hard | {
"lang": "rust",
"repo": "zhanif3/701",
"path": "/src/bin/bwt_rosalind.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn ROSALIND_TEST_TRUE() {
let T = "TTCCTAACG$A";
let L = generate_l(&T);
let F = generate_f(&T);
let Index: HashMap<Nucleotide, Nucleotide> = (0..T.len()).map(|i| {
(F[i], L[i])
}).collect();
... | code_fim | hard | {
"lang": "rust",
"repo": "zhanif3/701",
"path": "/src/bin/bwt_rosalind.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _instance = MySendStruct { value: 7 };
}
#[must_implement_trait(Send)]
struct MySendStruct<T: Send + Sync> {
value: T
}<|fim_prefix|>// repo: WasabiFan/must-implement-trait path: /tests/compilation_test_sources/struct_generics.rs
use must_implement_trait::must_implement_trait;
<|fim_middle|... | code_fim | easy | {
"lang": "rust",
"repo": "WasabiFan/must-implement-trait",
"path": "/tests/compilation_test_sources/struct_generics.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[must_implement_trait(Send)]
struct MySendStruct<T: Send + Sync> {
value: T
}<|fim_prefix|>// repo: WasabiFan/must-implement-trait path: /tests/compilation_test_sources/struct_generics.rs
use must_implement_trait::must_implement_trait;
fn main() {
<|fim_middle|> let _instance = MySendStruct { va... | code_fim | easy | {
"lang": "rust",
"repo": "WasabiFan/must-implement-trait",
"path": "/tests/compilation_test_sources/struct_generics.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WasabiFan/must-implement-trait path: /tests/compilation_test_sources/struct_generics.rs
use must_implement_trait::must_implement_trait;
<|fim_suffix|> let _instance = MySendStruct { value: 7 };
}
#[must_implement_trait(Send)]
struct MySendStruct<T: Send + Sync> {
value: T
}<|fim_middle|... | code_fim | easy | {
"lang": "rust",
"repo": "WasabiFan/must-implement-trait",
"path": "/tests/compilation_test_sources/struct_generics.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kornholi/mapeditor path: /src/opentibia/map.rs
use num::FromPrimitive;
use num_derive::FromPrimitive;
use std::io;
use crate::helpers::ReadExt;
use super::binaryfile;
use super::Position;
#[derive(Debug, FromPrimitive, PartialEq)]
enum NodeKind {
Root = 0,
MapData = 2,
ItemDef = 3... | code_fim | hard | {
"lang": "rust",
"repo": "kornholi/mapeditor",
"path": "/src/opentibia/map.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let raw_attr = data.read_byte()?;
let attribute_kind =
NodeAttributeKind::from_u8(raw_attr).expect("unknown attribute");
let attribute = match attribute_kind {
ItemCount | RuneCharges => ItemAttrib... | code_fim | hard | {
"lang": "rust",
"repo": "kornholi/mapeditor",
"path": "/src/opentibia/map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> _ => unreachable!(),
}
}
fn load_callback<F>(
&mut self,
kind: u8,
mut data: &[u8],
mut tile_callback: F,
) -> io::Result<bool>
where
F: FnMut(Position, &[Item]),
{
let kind = NodeKind::from_u8(kind).expect("unknown m... | code_fim | hard | {
"lang": "rust",
"repo": "kornholi/mapeditor",
"path": "/src/opentibia/map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let body = res.read_utf8_body().expect("failed to read response body");
assert_eq!(&body, "Hello, world!");
}<|fim_prefix|>// repo: djc/askama path: /askama_gotham/tests/basic.rs
use askama::Template;
use gotham::state::State;
use gotham::test::TestServer;
use hyper::StatusCode;
#[derive(Templat... | code_fim | hard | {
"lang": "rust",
"repo": "djc/askama",
"path": "/askama_gotham/tests/basic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: djc/askama path: /askama_gotham/tests/basic.rs
use askama::Template;
use gotham::state::State;
use gotham::test::TestServer;
use hyper::StatusCode;
#[derive(Template)]
#[template(path = "hello.html")]
struct HelloTemplate<'a> {
name: &'a str,
}
fn hello(state: State) -> (State, HelloTempla... | code_fim | hard | {
"lang": "rust",
"repo": "djc/askama",
"path": "/askama_gotham/tests/basic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gwang74/jlib-rs path: /src/base/mod.rs
extern crate secp256k1;
extern crate crypto;
extern crate ring;
pub mod data;
pub mod local_sign;
pub mod misc;
pub mod serialize;
pub mod wallet;
pub mod curve;
pub mod xcodec;
//Serialize
use std::collections::HashMap;
//针对key和value都是唯一的HashMap方法
pub t... | code_fim | hard | {
"lang": "rust",
"repo": "gwang74/jlib-rs",
"path": "/src/base/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Default)]
pub struct LedgerEntryTypeMap {
pub m: HashMap<&'static str, u16>,
}
impl LedgerEntryTypeMap {
pub fn new() -> Self {
let map: HashMap<&'static str, u16> =
[
("AccountRoot" , 97),
... | code_fim | hard | {
"lang": "rust",
"repo": "gwang74/jlib-rs",
"path": "/src/base/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: david68cu/rust-in-motion-videos path: /unit4/module8-lifetime-elision/02-01-second-rule-applies/src/main.rs
// The lifetime elision rules mean the compiler interprets this signature as if we had written:
// fn ex<'a>(color_name: &'a str, saturation: u8) -> &'a Color
fn ex(color_name: &str, satur... | code_fim | easy | {
"lang": "rust",
"repo": "david68cu/rust-in-motion-videos",
"path": "/unit4/module8-lifetime-elision/02-01-second-rule-applies/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct Color;
fn main() {}<|fim_prefix|>// repo: david68cu/rust-in-motion-videos path: /unit4/module8-lifetime-elision/02-01-second-rule-applies/src/main.rs
// The lifetime elision rules mean the compiler interprets this signature as if we had written:
// fn ex<'a>(color_name: &'a str, saturation: u8) -... | code_fim | easy | {
"lang": "rust",
"repo": "david68cu/rust-in-motion-videos",
"path": "/unit4/module8-lifetime-elision/02-01-second-rule-applies/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: berardino/skynet path: /src/main.rs
extern crate colored;
extern crate pnet;
use colored::*;
use pnet::datalink::{self};
use pnet::datalink::Channel::Ethernet;
use pnet::packet::Packet;
use pnet::packet::ethernet::{EthernetPacket, EtherTypes};
use pnet::packet::ip::IpNextHeaderProtocols;
use pn... | code_fim | hard | {
"lang": "rust",
"repo": "berardino/skynet",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let en0 = interfaces.iter()
.filter(|iface| iface.name == interface_name)
.next()
.unwrap();
println!();
println!("{} {}", "**** Found interface".yellow().bold(), interface_name);
println!();
// int socket(int domain, int type, int protocol);
// http://man... | code_fim | hard | {
"lang": "rust",
"repo": "berardino/skynet",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Giovan/lumen path: /lumen_runtime/src/test.rs
pub mod r#loop;
// wasm32 proptest cannot be compiled at the same time as non-wasm32 proptest, so disable tests that
// use proptest completely for wasm32
//
// See https://github.com/rust-lang/cargo/issues/4866
#[cfg(all(not(target_arch = "wasm32")... | code_fim | hard | {
"lang": "rust",
"repo": "Giovan/lumen",
"path": "/lumen_runtime/src/test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn monitored_count(process: &Process) -> usize {
process.monitored_pid_by_reference.lock().len()
}
pub fn receive_message(process: &Process) -> Option<Term> {
process
.mailbox
.lock()
.borrow_mut()
.receive(process)
.map(|result| result.unwrap())
}
sta... | code_fim | hard | {
"lang": "rust",
"repo": "Giovan/lumen",
"path": "/lumen_runtime/src/test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>static REGISTERED_NAME_COUNTER: AtomicUsize = AtomicUsize::new(0);
pub fn registered_name() -> Term {
atom_unchecked(
format!(
"registered{}",
REGISTERED_NAME_COUNTER.fetch_add(1, std::sync::atomic::Ordering::SeqCst)
)
.as_ref(),
)
}<|fim_prefix|>//... | code_fim | hard | {
"lang": "rust",
"repo": "Giovan/lumen",
"path": "/lumen_runtime/src/test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>new();
iter.into_iter().all(move |x| uniq.insert(x))
}<|fim_prefix|>// repo: rikharink/adventofcode path: /src/helpers/functions.rs
use std::collections::HashSet;
pub fn has_unique_elements<T>(iter: T) -> bool
where
T: IntoIterator,
T::I<|fim_middle|>tem: Eq + std::hash::Hash,
{
let mut ... | code_fim | easy | {
"lang": "rust",
"repo": "rikharink/adventofcode",
"path": "/src/helpers/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tem: Eq + std::hash::Hash,
{
let mut uniq = HashSet::new();
iter.into_iter().all(move |x| uniq.insert(x))
}<|fim_prefix|>// repo: rikharink/adventofcode path: /src/helpers/functions.rs
use std::collections::HashSet;
pub fn has_unique_element<|fim_middle|>s<T>(iter: T) -> bool
where
T: IntoIt... | code_fim | easy | {
"lang": "rust",
"repo": "rikharink/adventofcode",
"path": "/src/helpers/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rikharink/adventofcode path: /src/helpers/functions.rs
use std::collections::HashSet;
pub fn has_unique_element<|fim_suffix|>tem: Eq + std::hash::Hash,
{
let mut uniq = HashSet::new();
iter.into_iter().all(move |x| uniq.insert(x))
}<|fim_middle|>s<T>(iter: T) -> bool
where
T: IntoIt... | code_fim | easy | {
"lang": "rust",
"repo": "rikharink/adventofcode",
"path": "/src/helpers/functions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tokio::pin!(drive);
tokio::pin!(future);
self.rt
.block_on(self.local.run_until(crate::future::poll_fn(|cx| {
assert!(drive.as_mut().poll(cx).is_pending());
future.as_mut().poll(cx)
})))
})... | code_fim | hard | {
"lang": "rust",
"repo": "satanson/tokio-uring",
"path": "/src/runtime.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: satanson/tokio-uring path: /src/runtime.rs
use crate::driver::Driver;
use std::future::Future;
use std::io;
use tokio::io::unix::AsyncFd;
use tokio::task::LocalSet;
pub(crate) struct Runtime {
/// io-uring driver
driver: AsyncFd<Driver>,
/// LocalSet for !Send tasks
local: Loc... | code_fim | hard | {
"lang": "rust",
"repo": "satanson/tokio-uring",
"path": "/src/runtime.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl HttpResponse {
pub fn new() -> HttpResponse {
HttpResponse {
http_version: HttpVersion
}
}
}<|fim_prefix|>// repo: wradley/rust-virtual-network path: /src/http_response.rs
#path = ["http_version.rs"] mod http_version;
use std::collections::HashMap;
use http_versio... | code_fim | medium | {
"lang": "rust",
"repo": "wradley/rust-virtual-network",
"path": "/src/http_response.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wradley/rust-virtual-network path: /src/http_response.rs
#path = ["http_version.rs"] mod http_version;
use std::collections::HashMap;
use http_version::HttpVersion;
use http_version::http_version_string;
<|fim_suffix|>impl HttpResponse {
pub fn new() -> HttpResponse {
HttpResponse {... | code_fim | medium | {
"lang": "rust",
"repo": "wradley/rust-virtual-network",
"path": "/src/http_response.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>expect("Could not serialize state.");
}
pub fn get_raw_state(&self) -> Vec<u8> {
self.state.to_vec()
}
pub fn set_raw_state(&mut self, vec: Vec<u8>) {
self.state = vec;
}
}<|fim_prefix|>// repo: isgasho/laboratory path: /src/state.rs
use bincode::{serialize, deserializ... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/laboratory",
"path": "/src/state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/laboratory path: /src/state.rs
use bincode::{serialize, deserialize};
use serde::{Deserialize, Serialize};
pub struct State {
state: Vec<u8>
}
impl State {
pub fn new() -> State {
State { state: vec![] }
}
pub fn get_state<'a, T>(&'a self) -> T
where
... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/laboratory",
"path": "/src/state.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>onvert from string")
}
pub fn set_state<T: Serialize>(& mut self, state: T) {
// self.state = to_string(&state).expect("Could not convert to String.");
self.state = serialize(&state).expect("Could not serialize state.");
}
pub fn get_raw_state(&self) -> Vec<u8> {
se... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/laboratory",
"path": "/src/state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match serde_json::from_str::<Self>(&json) {
Ok(task) => {
return Ok(task);
}
Err(e) => {
println!("json: {}", &json);
println!("{}", e.to_string());
match serde_json::from_str::<serde_json::Value>(&... | code_fim | hard | {
"lang": "rust",
"repo": "gokayokyay/stewardx",
"path": "/src/tasks/docker_async/task.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // return Err(Self::prop_not_found(String::from("aa")));
let env = &value["env"].as_array().map_or(Vec::new(), |a| {
let vec_value = a.to_vec();
vec_value.iter().fold(Vec::default(), |mut env_value, a| {
match a {
serde_json::Valu... | code_fim | hard | {
"lang": "rust",
"repo": "gokayokyay/stewardx",
"path": "/src/tasks/docker_async/task.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gokayokyay/stewardx path: /src/tasks/docker_async/task.rs
use futures::StreamExt;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use shiplift::{tty::TtyChunk, ContainerOptions, PullOptions};
use tempfile::{Builder, TempDir};
use uuid::Uuid;
use crate::models::TaskError;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "gokayokyay/stewardx",
"path": "/src/tasks/docker_async/task.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let box_1 = PipeBox::new();
let box_2 = PipeBox::new();
let box_2 = box_2.set_control(|x| {
if x.get_item().as_str() == "Il fait chaud ici !".to_string() {
println!("C'est pas bon");
PipeState::RestartState
}
else... | code_fim | hard | {
"lang": "rust",
"repo": "CyberWolf37/pipe",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CyberWolf37/pipe path: /src/lib.rs
mod model;
use std::sync::Arc;
#[derive(Clone)]
pub enum PipeState {
NextState,
RestartState,
WaitState,
ConsumeState,
}
pub trait PipeU: PartialEq {
type Item;
fn get_item(&self) -> &Self::Item;
}
pub trait PipeB<T: PipeU> {
f... | code_fim | hard | {
"lang": "rust",
"repo": "CyberWolf37/pipe",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Context {
pub fn new(context: &TransactionContext) -> Context {
Context {
channel_id : context.channel_id.clone(),
tx_id: context.transaction_id.clone()
}
}
pub fn get_txid(&self) -> std::string::String {
return self.tx_id.clone();
}
... | code_fim | medium | {
"lang": "rust",
"repo": "mbwhite/fabric-contract-api-rust",
"path": "/fabric_contract/src/contractapi/context.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbwhite/fabric-contract-api-rust path: /fabric_contract/src/contractapi/context.rs
/*
* SPDX-License-Identifier: Apache-2.0
*/
use fabric_ledger_protos::common_messages::TransactionContext;
<|fim_suffix|> pub fn get_txid(&self) -> std::string::String {
return self.tx_id.clone();
... | code_fim | hard | {
"lang": "rust",
"repo": "mbwhite/fabric-contract-api-rust",
"path": "/fabric_contract/src/contractapi/context.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// An extension of the NdArray float type
pub trait Float: NdFloat + Default + Clone + std::iter::Sum {}
impl Float for f32 {}
impl Float for f64 {}
/// SMO can either exit because a threshold is reached or the iterations are maxed out
#[derive(Debug)]
pub enum ExitReason {
ReachedThreshold,
Re... | code_fim | hard | {
"lang": "rust",
"repo": "fgadaleta/linfa",
"path": "/linfa-svm/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Support Vector Regression
#[allow(non_snake_case)]
pub mod SVRegress {
pub use crate::regression::{fit_epsilon, fit_nu};
}
/// An extension of the NdArray float type
pub trait Float: NdFloat + Default + Clone + std::iter::Sum {}
impl Float for f32 {}
impl Float for f64 {}
/// SMO can either exi... | code_fim | hard | {
"lang": "rust",
"repo": "fgadaleta/linfa",
"path": "/linfa-svm/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fgadaleta/linfa path: /linfa-svm/src/lib.rs
//! Support Vector Machines
//!
//! Support Vector Machines are one major branch of machine learning models and offer classification or
//! regression analysis of labeled datasets. They seek a discriminant, which seperates the data in
//! an optimal wa... | code_fim | hard | {
"lang": "rust",
"repo": "fgadaleta/linfa",
"path": "/linfa-svm/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn load() -> Result<Lines, Box<dyn Error>> {
let file = File::open(CHATWHEEL_ALL_PATH)?;
let reader = BufReader::new(file);
let lines: Lines = serde_json::from_reader(reader)?;
Ok(lines)
}<|fim_prefix|>// repo: lausek/chatwheel-rs path: /src/line.rs
use serde::{Deserialize, Serialize}... | code_fim | hard | {
"lang": "rust",
"repo": "lausek/chatwheel-rs",
"path": "/src/line.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lausek/chatwheel-rs path: /src/line.rs
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::error::Error;
use std::fs::File;
use std::io::BufReader;
use crate::consts::CHATWHEEL_ALL_PATH;
pub type Lines = HashMap<String, Line>;
<|fim_suffix|>pub fn load() -> Result<Lin... | code_fim | medium | {
"lang": "rust",
"repo": "lausek/chatwheel-rs",
"path": "/src/line.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MemoryChips/v6-rust path: /src/lib.rs
#[macro_use]
extern crate log;
extern crate gl;
extern crate glam;
extern crate glfw;
pub mod renderer;
pub mod shader;
pub mod texture;
pub mod timer;
pub mod window;
pub mod v6_core {
use super::shader;
use super::timer::Timer;
use std::str;
pub... | code_fim | hard | {
"lang": "rust",
"repo": "MemoryChips/v6-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let glfw: glfw::Glfw = glfw::init(glfw::FAIL_ON_ERRORS).expect("Unable to initialize glfw");
let (window, window_events) = glfw
.create_window(
props.w,
props.h,
&props.title,
// "English 日本語 русский язык 官話",
glfw::WindowMode::Windowed... | code_fim | hard | {
"lang": "rust",
"repo": "MemoryChips/v6-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakob-ledermann/wasm-game-of-live path: /src/universe_builder.rs
use wasm_bindgen::prelude::*;
use crate::{Cell, Universe, utils};
#[wasm_bindgen]
pub struct EmptyUniverse;
#[wasm_bindgen]
pub struct UniverseWithWidth {
width: usize
}
#[wasm_bindgen]
pub struct UniverseWithHeight {
h... | code_fim | hard | {
"lang": "rust",
"repo": "jakob-ledermann/wasm-game-of-live",
"path": "/src/universe_builder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let width = self.width;
let height = self.height;
let mut cells = vec![Cell::Dead; width * height];
for index in 0..cells.len()
{
let random = random();
cells[index] = if random < 0.5 { Cell::Alive } else { Cell::Dead }
}
Uni... | code_fim | hard | {
"lang": "rust",
"repo": "jakob-ledermann/wasm-game-of-live",
"path": "/src/universe_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xentrick/rustpacket path: /src/pcap/pcap.rs
use byteorder::ByteOrder;
use chrono::NaiveDateTime;
use std::ops::Range;
use std::fmt;
use super::error::{Error, Result};
use super::linktype::LinkType;
use super::types::{Endianness, require_bytes};
use super::reader::{
MAGIC_NANO_SECONDS_LITTLE... | code_fim | hard | {
"lang": "rust",
"repo": "xentrick/rustpacket",
"path": "/src/pcap/pcap.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Parse ts_sec and ts_usec as u32 per the spec
// instead of i64 for NaiveDateTime. This probably
// doesn't matter at all but I like following the rules.
let sec = B::read_u32(&buf[..4]);
// Multiply by the factor determined from the pcap magic
// to get a... | code_fim | hard | {
"lang": "rust",
"repo": "xentrick/rustpacket",
"path": "/src/pcap/pcap.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CertainLach/noise-rust path: /rust-crypto/src/lib.rs
use crypto::aead::{AeadDecryptor, AeadEncryptor};
use crypto::aes::KeySize;
use crypto::aes_gcm::AesGcm;
use crypto::chacha20::ChaCha20;
use crypto::curve25519::{curve25519, curve25519_base};
use crypto::digest::Digest;
use crypto::mac::Mac;
u... | code_fim | hard | {
"lang": "rust",
"repo": "CertainLach/noise-rust",
"path": "/rust-crypto/src/lib.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.