text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> fn items(self) -> Vec<Light> {
self.lights
}
}
#[test]
fn will_fill_the_grid_with_lights_in_default_state() {
let width = 5;
let height = 5;
let mut grid = LightGrid {
width,
height,
lights: Vec::new(),
};
&grid.fill();
// iterate over each... | code_fim | hard | {
"lang": "rust",
"repo": "theatlasroom/advent-of-code",
"path": "/rust/src/aoc2015_6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Talentica/simpleblockchain path: /src/utils/src/logger.rs
extern crate chrono;
use log4rs::init_file;
pub fn logger_init_from_yml(file_path: &str) {
init_file(&String::from(file_path), Default::default()).unwrap();
}
<|fim_suffix|> logger_init_from_yml("log.yml");
info!("ym... | code_fim | hard | {
"lang": "rust",
"repo": "Talentica/simpleblockchain",
"path": "/src/utils/src/logger.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger_init_from_yml("log.yml");
info!("yml logger is working");
}
}<|fim_prefix|>// repo: Talentica/simpleblockchain path: /src/utils/src/logger.rs
extern crate chrono;
use log4rs::init_file;
pub fn logger_init_from_yml(file_path: &str) {
init_file(&String::from(file_path), Def... | code_fim | hard | {
"lang": "rust",
"repo": "Talentica/simpleblockchain",
"path": "/src/utils/src/logger.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Canop/lapin path: /src/edit/pen.rs
use {
crate::{
core::Terrain,
persist::Level,
pos::*,
},
super::{
drawing_action::*,
ink::*,
},
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PenShape {
Dot,
Line,
Rect,
}
pub stati... | code_fim | hard | {
"lang": "rust",
"repo": "Canop/lapin",
"path": "/src/edit/pen.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new_for(level: &Level) -> Self {
Self {
shape: PenShape::Dot,
ink: Ink::Terrain(if level.default_terrain==Terrain::Mud {
Terrain::Stone
} else {
Terrain::Mud
}),
shape_start: None,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Canop/lapin",
"path": "/src/edit/pen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cjayross/solovay_strassen path: /src/lib.rs
//! # Quick Start
//!
//! Contained within this module are two functions:
//! * `is_witness`
//! * `is_prime`
//!
//! The function `is_witness` performs a single iteration of the Solovay-Strassen
//! primality test.
//!
//! On the other hand, `is_p... | code_fim | hard | {
"lang": "rust",
"repo": "cjayross/solovay_strassen",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if n == One::one() {
res
} else {
Zero::zero()
}
}
fn __solovay_strassen(a: &BigUint, n: &BigUint) -> bool {
let x: BigInt = legendre_symbol(a.clone(), n.clone());
x == Zero::zero() || x.mod_floor(&bigint!(n)) != bigint!(a.modpow(&((n - 1u8) / 2u8), n))
}
/// Test wh... | code_fim | hard | {
"lang": "rust",
"repo": "cjayross/solovay_strassen",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::*;
use std::io;
#[test]
fn test_prime() -> io::Result<()> {
let prime: u64 = 0x7FFF_FFFF;
assert!(is_prime(&prime, K));
Ok(())
}
#[test]
fn test_composite() -> io::Result<()> {
let composite: u64 = 0x7FFF_FFFE;
assert!(!is_pr... | code_fim | hard | {
"lang": "rust",
"repo": "cjayross/solovay_strassen",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let async_pin_poller = pin.get_async_poller().unwrap();
poll.register(&async_pin_poller, token, Ready::readable(), PollOpt::edge()).unwrap();
async_pin_poller // Need to keep a valid reference to the async poller
})
.collect();
let mut events = Events::with_capacity(1024);
l... | code_fim | hard | {
"lang": "rust",
"repo": "rosie-home-automation/garage_rfid",
"path": "/examples/mio_evented.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rosie-home-automation/garage_rfid path: /examples/mio_evented.rs
/**
* An example to workout how to use async pin pollers through mio evented.
* Also learned how to use features with cargo.
* This example requires a raspberry pi.
*/
#[cfg(feature = "mio-evented")]
extern crate mio;
#[cfg(fe... | code_fim | hard | {
"lang": "rust",
"repo": "rosie-home-automation/garage_rfid",
"path": "/examples/mio_evented.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pin_nums = [(17, TOKEN_0), (27, TOKEN_1)];
// let pin_nums = [(17, TOKEN_0)];
let pins: Vec<_> = pin_nums.iter()
.map(|&(pin_num, token)| (token, Pin::new(pin_num)))
.collect();
let poll = Poll::new()?;
let async_pin_pollers: Vec<AsyncPinPoller> = pins.iter()
.map(|&(token, ref ... | code_fim | hard | {
"lang": "rust",
"repo": "rosie-home-automation/garage_rfid",
"path": "/examples/mio_evented.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
impl PHY_SELECT_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> PHY_SELECT_A {
match self.bits {
false => PHY_SELECT_A::EXTERNAL,
true => PHY_SELECT_A::INTERNAL,
}
}
#[doc... | code_fim | hard | {
"lang": "rust",
"repo": "duskmoon314/aw-pac",
"path": "/d1-pac/src/sys_cfg/emac_ephy_clk0.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: duskmoon314/aw-pac path: /d1-pac/src/sys_cfg/emac_ephy_clk0.rs
pub type RMII_EN_R = crate::BitReader<RMII_EN_A>;
#[doc = "\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RMII_EN_A {
#[doc = "0: `0`"]
DISABLE = 0,
#[doc = "1: `1`"]
ENABLE = 1,
}
impl... | code_fim | hard | {
"lang": "rust",
"repo": "duskmoon314/aw-pac",
"path": "/d1-pac/src/sys_cfg/emac_ephy_clk0.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
impl XMII_SEL_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> XMII_SEL_A {
match self.bits {
false => XMII_SEL_A::INTERNAL,
true => XMII_SEL_A::EXTERNAL,
}
}
#[doc = "Chec... | code_fim | hard | {
"lang": "rust",
"repo": "duskmoon314/aw-pac",
"path": "/d1-pac/src/sys_cfg/emac_ephy_clk0.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub struct Block {
pub pos: Address,
pub size: Size,
pub status: BlockStatus,
}<|fim_prefix|>// repo: Rupsbant/ddrescue_iso_check path: /ddrescue_mapfile/src/data.rs
#[derive(Debug, PartialEq, Eq, Ord, PartialOrd, Clone, Copy, Hash)]
pub stru... | code_fim | hard | {
"lang": "rust",
"repo": "Rupsbant/ddrescue_iso_check",
"path": "/ddrescue_mapfile/src/data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rupsbant/ddrescue_iso_check path: /ddrescue_mapfile/src/data.rs
#[derive(Debug, PartialEq, Eq, Ord, PartialOrd, Clone, Copy, Hash)]
pub struct Address(pub u64);
#[derive(Debug, PartialEq, Eq, Ord, PartialOrd, Clone, Copy, Hash)]
pub struct Pass(pub u64);
#[derive(Debug, PartialEq, Eq, Ord, Parti... | code_fim | hard | {
"lang": "rust",
"repo": "Rupsbant/ddrescue_iso_check",
"path": "/ddrescue_mapfile/src/data.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HarrisonMc555/task-planner path: /task-planner-server/src/bin/add_user.rs
extern crate diesel;
extern crate task_planner_server;
use self::task_planner_server::{connection::*, users::*};
use std::io::stdin;
<|fim_suffix|> Err(diesel::result::Error::DatabaseError(
die... | code_fim | hard | {
"lang": "rust",
"repo": "HarrisonMc555/task-planner",
"path": "/task-planner-server/src/bin/add_user.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Enter your name");
let mut display_name = String::new();
stdin().read_line(&mut display_name).unwrap();
let display_name = display_name.trim_end();
println!("Choose a username");
let mut username_buffer = String::new();
let user;
loop {
username_buffer.cl... | code_fim | medium | {
"lang": "rust",
"repo": "HarrisonMc555/task-planner",
"path": "/task-planner-server/src/bin/add_user.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>= crate::FR<u8, u8>;
impl R {
#[doc = r"Value of the register as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bits 0:7 - Preamble"]
#[inline(always)]
pub fn preamble(&self) -> PREAMBLE_R {
PREAMBLE_R::new((self.bits() & 0xff) as ... | code_fim | medium | {
"lang": "rust",
"repo": "pklazy/lpc54628-rust",
"path": "/src/etm/cidr0.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pklazy/lpc54628-rust path: /src/etm/cidr0.rs
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
impl super::CIDR0 {
#[doc = r"Reads the contents of the register"]
#[inline(always)]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
... | code_fim | medium | {
"lang": "rust",
"repo": "pklazy/lpc54628-rust",
"path": "/src/etm/cidr0.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theocrowley24/Cinema-Backend path: /src/helpers/multipart_parsing.rs
use std::collections::HashMap;
use std::io::Write;
use actix_multipart::Multipart;
use actix_web::web;
use futures::{StreamExt, TryStreamExt};
use serde::de::DeserializeOwned;
use uuid::Uuid;
pub struct MultipartFile {
pu... | code_fim | hard | {
"lang": "rust",
"repo": "theocrowley24/Cinema-Backend",
"path": "/src/helpers/multipart_parsing.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
This function takes a type argument D which implements Deserialize and a Multipart.
It returns a ParsedMultipart<D>.
*/
pub async fn attempt_parse_multipart<D: DeserializeOwned>(mut multipart: Multipart<>) -> Result<ParsedMultipart<D>, &'static str> {
let mut mime_type_extensions: HashMap<&... | code_fim | hard | {
"lang": "rust",
"repo": "theocrowley24/Cinema-Backend",
"path": "/src/helpers/multipart_parsing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file_ext = mime_type_extensions.get(mime.as_str()).unwrap();
let uid = Uuid::new_v4();
let filepath = format!("/tmp/{}.{}", &uid, file_ext); // Assuming Unix system
let filepath_copy = filepath.clone();
let mut file = web::block(|| std::fs:... | code_fim | hard | {
"lang": "rust",
"repo": "theocrowley24/Cinema-Backend",
"path": "/src/helpers/multipart_parsing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Position and size the background
let center_x = context.size.width * 0.5;
let center_y = context.size.height * 0.5;
self.background_node.set_shape(&Rectangle::new(
context.session().clone(),
context.size.width,
context.size.height,
... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/garnet/public/rust/carnelian/examples/button.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: winksaville/fuchsia path: /garnet/public/rust/carnelian/examples/button.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 carnelian::{
make_message, set_node_color, App, ... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/garnet/public/rust/carnelian/examples/button.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> _: *const libc::c_char);
}
/* _ss_h */
}
#[c2rust::header_src = "/usr/include/stdio.h:9"]
pub mod stdio_h {
extern "C" {
#[no_mangle]
#[c2rust::src_loc = "332:12"]
pub fn printf(_: *const libc::c_char, _: ...) -> libc::c_int;
}
}
pub use self::ss_intern... | code_fim | hard | {
"lang": "rust",
"repo": "xentrick/gssapi-rs",
"path": "/src/util/ss/requests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xentrick/gssapi-rs path: /src/util/ss/requests.rs
use ::libc;
use ::c2rust_bitfields;
#[c2rust::header_src =
"/home/nmavis/dev/gssapi-rs/code/src/util/ss/ss_internal.h:10"]
pub mod ss_internal_h {
#[c2rust::src_loc = "13:1"]
pub type pointer = *mut libc::c_void;
#[derive(Copy, Clon... | code_fim | hard | {
"lang": "rust",
"repo": "xentrick/gssapi-rs",
"path": "/src/util/ss/requests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mut info_ptr: pointer) {
printf(b"%s\n\x00" as *const u8 as *const libc::c_char,
(**_ss_table.offset(sci_idx as isize)).subsystem_name);
}
/*
* ss_subsystem_version -- print version of subsystem
*/
#[no_mangle]
#[c2rust::src_loc = "35:1"]
pub unsafe extern "C" fn... | code_fim | hard | {
"lang": "rust",
"repo": "xentrick/gssapi-rs",
"path": "/src/util/ss/requests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fenex/lloth path: /src/channel/tcp.rs
use std::{
alloc::Layout,
convert::TryFrom,
future::Future,
io::{Error, ErrorKind},
mem::{size_of, size_of_val},
pin::Pin,
ptr::copy_nonoverlapping,
task::{Context, Poll},
};
use alkahest::{Pack, Schema, Unpacked};
use scoped... | code_fim | hard | {
"lang": "rust",
"repo": "Fenex/lloth",
"path": "/src/channel/tcp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match result {
Ok(read) => {
if read == 0 {
return Err(std::io::ErrorKind::ConnectionAborted.into());
} else {
self.buf_len += read;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Fenex/lloth",
"path": "/src/channel/tcp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/rocket/src/data/data_stream.rs
use std::io::{self, Read, Cursor, Chain};
use std::net::Shutdown;
use super::data::BodyReader;
use crate::http::hyper::net::NetworkStream;
use crate::http::hyper::h1::HttpReader;
// |-- peek buf --|
... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-io",
"path": "/vendor/rocket/src/data/data_stream.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Take <= 1k from the stream. If there might be more data, force close.
const FLUSH_LEN: u64 = 1024;
match io::copy(&mut stream.take(FLUSH_LEN), &mut io::sink()) {
Ok(FLUSH_LEN) | Err(_) => {
warn_!("Data left unread. Force closing network stream.");
let (_, ne... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-io",
"path": "/vendor/rocket/src/data/data_stream.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> trace_!("DataStream::read()");
self.0.read(buf)
}
}
pub fn kill_stream(stream: &mut BodyReader) {
// Only do the expensive reading if we're not sure we're done.
use self::HttpReader::*;
match *stream {
SizedReader(_, n) | ChunkedReader(_, Some(n)) if n > 0 => { /* ... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-io",
"path": "/vendor/rocket/src/data/data_stream.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn de(&self) -> u16 {
u16::from_le_bytes([self.e, self.d])
}
pub fn set_hl(&mut self, value: u16) {
let bytes = value.to_le_bytes();
self.l = bytes[0];
self.h = bytes[1];
}
pub fn hl(&self) -> u16 {
u16::from_le_bytes([self.l, self.h])
... | code_fim | hard | {
"lang": "rust",
"repo": "hmarthinsen/gaby",
"path": "/src/cpu/registers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hmarthinsen/gaby path: /src/cpu/registers.rs
use crate::cpu::operands::{ByteRegister, WordRegister};
use bitflags::bitflags;
bitflags! {
pub struct Flags: u8 {
const Z = 0b1000_0000; // Zero
const N = 0b0100_0000; // Negative
const H = 0b0010_0000; // Half-carry
... | code_fim | hard | {
"lang": "rust",
"repo": "hmarthinsen/gaby",
"path": "/src/cpu/registers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Spawn a new terminal, with an optional file to open in a terminal program.
fn spawn_terminal(&mut self, file_to_open: Option<PathBuf>) -> (RawFd, RawFd);
/// Read bytes from the standard output of the virtual terminal referred to by `fd`.
fn read_from_tty_stdout(&mut self, fd: RawFd, b... | code_fim | hard | {
"lang": "rust",
"repo": "qballer/zellij",
"path": "/src/common/os_input_output.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qballer/zellij path: /src/common/os_input_output.rs
use crate::panes::PositionAndSize;
use nix::fcntl::{fcntl, FcntlArg, OFlag};
use nix::pty::{forkpty, Winsize};
use nix::sys::signal::{kill, Signal};
use nix::sys::termios;
use nix::sys::wait::waitpid;
use nix::unistd;
use nix::unistd::{ForkResu... | code_fim | hard | {
"lang": "rust",
"repo": "qballer/zellij",
"path": "/src/common/os_input_output.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Sets the size of the terminal associated to file descriptor `fd`.
fn set_terminal_size_using_fd(&mut self, fd: RawFd, cols: u16, rows: u16);
/// Set the terminal associated to file descriptor `fd` to
/// [raw mode](https://en.wikipedia.org/wiki/Terminal_mode).
fn set_raw_mode(&mut ... | code_fim | hard | {
"lang": "rust",
"repo": "qballer/zellij",
"path": "/src/common/os_input_output.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl core::fmt::Debug for dyn TurtlePower {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "TurtlePower")
}
}
#[derive(Debug)]
pub struct Wand {
charges: u32,
}
impl Wand {
pub fn new(charges: u32) -> Wand {
Wand { charges }
}
}
impl... | code_fim | medium | {
"lang": "rust",
"repo": "scosta18/CMSC330-projects",
"path": "/project5b/traditional_rust/campus1/src/magic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.charges > 0 {
world.sound(String::from("ZAP!"));
self.charges -= 1;
}
}
}
#[derive(Debug)]
pub struct Crystal {}
impl Crystal {
pub fn new() -> Crystal {
Crystal {}
}
}
impl TurtlePower for Crystal {
/**
* Crystals last foreve... | code_fim | hard | {
"lang": "rust",
"repo": "scosta18/CMSC330-projects",
"path": "/project5b/traditional_rust/campus1/src/magic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scosta18/CMSC330-projects path: /project5b/traditional_rust/campus1/src/magic.rs
/**
* DO NOT EDIT THIS FILE. When testing your code, we will
* replace this file with our own version!
*/
#[derive(Debug)]
pub struct World {}
impl World {
pub fn sound(&mut self, utterance: String) {
... | code_fim | medium | {
"lang": "rust",
"repo": "scosta18/CMSC330-projects",
"path": "/project5b/traditional_rust/campus1/src/magic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>push result {} back", value1, value2, result);
frame.stack_push(Primitive::Int(result));
Some(pc + 1)
}<|fim_prefix|>// repo: Pfarrer/rust-jvm path: /_deprecated/src/vm/eval/imul.rs
use vm::Vm;
use vm::primitive::Primitive;
pub fn eval(vm: &mut Vm, pc: u16) -> Option<u16> {
let frame = v<|f... | code_fim | hard | {
"lang": "rust",
"repo": "Pfarrer/rust-jvm",
"path": "/_deprecated/src/vm/eval/imul.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pfarrer/rust-jvm path: /_deprecated/src/vm/eval/imul.rs
use vm::Vm;
use vm::primitive::Primitive;
pub fn eval(vm: &mut Vm, pc: u16) -> Option<u16> {
let frame = vm.frame_stack.last_mut().unwrap();
let value2 = frame.stack_pop_int();
let value1 = frame.stack_pop_int<|fim_suffix|>push... | code_fim | medium | {
"lang": "rust",
"repo": "Pfarrer/rust-jvm",
"path": "/_deprecated/src/vm/eval/imul.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clucompany/cluFlock path: /examples/raw_file.rs
/*
Using only the file pointer for locks. Unsafe is required since it's not
a complete file object, just a raw pointer to it.
*/
use cluFlock::SharedFlock;
use cluFlock::rawfile::GetRawFile;
use std::io::Error;
use std::fs::File;
fn main() ->... | code_fim | medium | {
"lang": "rust",
"repo": "clucompany/cluFlock",
"path": "/examples/raw_file.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Case2: random file address
#[cfg(any(linux, unix, bsd))] {
use cluFlock::rawfile::RawFile;
let raw_file = unsafe {
RawFile::from_ptr(2)
};
println!("Case2 {:?}", raw_file);
let shared2 = SharedFlock::try_lock(raw_file);
println!("{:?}", shared2);
/*
It's funny that you can blo... | code_fim | hard | {
"lang": "rust",
"repo": "clucompany/cluFlock",
"path": "/examples/raw_file.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let raw_file = unsafe {
RawFile::from_ptr(2)
};
println!("Case2 {:?}", raw_file);
let shared2 = SharedFlock::try_lock(raw_file);
println!("{:?}", shared2);
/*
It's funny that you can block input and output streams.
*/
}
Ok(())
}<|fim_prefix|>// repo: clucompany/cluFlock path: /ex... | code_fim | hard | {
"lang": "rust",
"repo": "clucompany/cluFlock",
"path": "/examples/raw_file.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mengsuenyan/rcrypto path: /src/sha3/shake.rs
//! [KECCAK](keccak.noekeon.org)
//!
//! SHA-3: FIPS-202
//!
//! https://www.cnblogs.com/mengsuenyan/p/13182759.html
//!
//! KECCAK[c] = SPONGE[KECCAK-p[1600, 24], pad10*1, 1600-c];
//! KECCAK[c](N, d) = SPONGE[KECCAK-p[1600, 24], pad10*1,... | code_fim | hard | {
"lang": "rust",
"repo": "mengsuenyan/rcrypto",
"path": "/src/sha3/shake.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.want_bits_len
}
fn write(&mut self, data: &[u8]) {
self.sponge.write_to_buf(data, data.len() << 3);
self.is_checked = false;
}
fn checksum(&mut self, digest: &mut Vec<u8>... | code_fim | hard | {
"lang": "rust",
"repo": "mengsuenyan/rcrypto",
"path": "/src/sha3/shake.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/oxide.rs-old path: /oxide/src/networkings.rs
page = "".to_string();
}
}
// Return our response data.
Ok(items)
}
/**
* This function performs a `POST` to the `/organizations/{organization_name}/projects/{project_name}/vpc... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/oxide.rs-old",
"path": "/oxide/src/networkings.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !resp.next_page.is_empty() && resp.next_page != page {
page = resp.next_page.to_string();
} else {
page = "".to_string();
}
}
// Return our response data.
Ok(items)
}
/**
* This... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/oxide.rs-old",
"path": "/oxide/src/networkings.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>self.client.put(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?))).await
}
/**
* This function performs a `DELETE` to the `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers/{router_name}` endpoint.
*
* Delete a router from its VPC
*
* **Parameters:**
*
* * `organ... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/oxide.rs-old",
"path": "/oxide/src/networkings.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: henryscala/leetcode path: /rs/p027_quadratic_prime.rs
//problem 27 of project euler
fn main() {
println!("{} is prime {}",4,is_prime(4));
println!("{} is prime {}",7,is_prime(7));
println!("{} is prime {}",3,is_prime(3));
println!("{} is prime {}",2,is_prime(2));
printl... | code_fim | hard | {
"lang": "rust",
"repo": "henryscala/leetcode",
"path": "/rs/p027_quadratic_prime.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn max_consecutive_primes(){
let mut max_n:i32 = 0;
let mut max_a:i32 ;
let mut max_b:i32 ;
for a in -1000..1000 {
for b in -1000..1000 {
let n=consecutive_num_primes(a,b);
if n > max_n {
max_n = n;
max_a = a;
... | code_fim | hard | {
"lang": "rust",
"repo": "henryscala/leetcode",
"path": "/rs/p027_quadratic_prime.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: justinmchase/verse-lang path: /src/runtime/ops/reference.rs
use super::super::{Context, RuntimeError, Value, Verse};
use std::rc::Rc;
pub fn reference(_: Rc<Verse>, context: Rc<Context>, name: String) -> Result<Value, RuntimeError> {
let val = context.get_var(name.to_string());
println!(" ... | code_fim | medium | {
"lang": "rust",
"repo": "justinmchase/verse-lang",
"path": "/src/runtime/ops/reference.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn reference_returns_error() {
let v = Verse::default();
let c = v.create_context();
let r = reference(Rc::new(v), c, String::from("x"));
assert_eq!(
r,
Err(RuntimeError::InvalidReferenceError(
String::from("x").to_string()
))
);
}
}<|fim_prefix|... | code_fim | medium | {
"lang": "rust",
"repo": "justinmchase/verse-lang",
"path": "/src/runtime/ops/reference.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let v = Verse::default();
let c = v.create_context();
c.add_var(String::from("x").to_string(), Value::Int(1));
let r = reference(Rc::new(v), c, String::from("x"));
assert_eq!(r, Ok(Value::Int(1)));
}
#[test]
fn reference_returns_error() {
let v = Verse::default();
let c... | code_fim | medium | {
"lang": "rust",
"repo": "justinmchase/verse-lang",
"path": "/src/runtime/ops/reference.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cstanfill/brodg path: /src/lib.rs
pub mod contract;
pub mod data;
pub mod interface;
pub mod parse;
pub mod score;
#[cfg(test)]
use data::score_game;
#[cfg(test)]
use parse::parse_contract;
#[test]
fn score_3s_v_p3() {
<|fim_suffix|> assert!(score_game(parse_contract("6CXX").unwrap(), 1, tr... | code_fim | hard | {
"lang": "rust",
"repo": "cstanfill/brodg",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn score_3s_v_p3() {
assert!(score_game(parse_contract("3S").unwrap(), 3, true) == 230);
}
#[test]
fn score_2nt_d_p4() {
assert!(score_game(parse_contract("2NTX").unwrap(), 4, false) == 890);
}
#[test]
fn score_d_m6() {
assert!(score_game(parse_contract("1SX").unwrap(), -6, false) ==... | code_fim | medium | {
"lang": "rust",
"repo": "cstanfill/brodg",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe impl<'a, T, A> Send for Producer<'a, T, A>
where
A: Unsize<[T]>,
T: Send,
{
}
#[cfg(test)]
mod tests {
use RingBuffer;
#[test]
fn sanity() {
static mut RB: RingBuffer<i32, [i32; 2]> = RingBuffer::new();
let (mut p, mut c) = unsafe { RB.split() };
asse... | code_fim | hard | {
"lang": "rust",
"repo": "perlindgren/heapless",
"path": "/src/ring_buffer/spsc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: perlindgren/heapless path: /src/ring_buffer/spsc.rs
use core::marker::{PhantomData, Unsize};
use core::ptr::{self, Shared};
use BufferFullError;
use ring_buffer::RingBuffer;
impl<T, A> RingBuffer<T, A>
where
A: Unsize<[T]>,
{
/// Splits a statically allocated ring buffer into producer ... | code_fim | hard | {
"lang": "rust",
"repo": "perlindgren/heapless",
"path": "/src/ring_buffer/spsc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peterhj/libcuda path: /src/ffi/v7_5/_cuda_runtime_api.rs
/* automatically generated by rust-bindgen */
extern "C" {
pub fn cudaDeviceReset() -> cudaError_t;
}
extern "C" {
pub fn cudaDeviceSynchronize() -> cudaError_t;
}
extern "C" {
pub fn cudaGetErrorString(error: cudaError_t) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "peterhj/libcuda",
"path": "/src/ffi/v7_5/_cuda_runtime_api.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>aMemcpy2DAsync(
dst: *mut ::std::os::raw::c_void,
dpitch: usize,
src: *const ::std::os::raw::c_void,
spitch: usize,
width: usize,
height: usize,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
extern "C" {
pub fn cudaM... | code_fim | hard | {
"lang": "rust",
"repo": "peterhj/libcuda",
"path": "/src/ffi/v7_5/_cuda_runtime_api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..1<<k {
println!("{}", dp[k][i]);
}
dbg!(dp[k].iter().sum::<f64>());
}<|fim_prefix|>// repo: emakryo/cmpro path: /src/typicalDP/src/bin/c.rs
#![allow(unused_macros, unused_imports)]
macro_rules! dbg {
($($xs:expr),+) => {
if cfg!(debug_assertions) {
... | code_fim | hard | {
"lang": "rust",
"repo": "emakryo/cmpro",
"path": "/src/typicalDP/src/bin/c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emakryo/cmpro path: /src/typicalDP/src/bin/c.rs
#![allow(unused_macros, unused_imports)]
macro_rules! dbg {
($($xs:expr),+) => {
if cfg!(debug_assertions) {
std::dbg!($($xs),+)
} else {
($($xs),+)
}
}
}
<|fim_suffix|> let mut dp = vec![... | code_fim | medium | {
"lang": "rust",
"repo": "emakryo/cmpro",
"path": "/src/typicalDP/src/bin/c.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for l in s..t {
dp[i+1][j] += dp[i][j] * dp[i][l] / (1.0 + 10.0f64.powf((r[l]-r[j])/400.0));
}
}
}
for i in 0..1<<k {
println!("{}", dp[k][i]);
}
dbg!(dp[k].iter().sum::<f64>());
}<|fim_prefix|>// repo: emakryo/cmpro path: /src/typi... | code_fim | hard | {
"lang": "rust",
"repo": "emakryo/cmpro",
"path": "/src/typicalDP/src/bin/c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", wonderful_substrings(String::from("aba"))); // 4
println!("{}", wonderful_substrings(String::from("aabb"))); // 9
println!("{}", wonderful_substrings(String::from("he"))); // 2
println!("{}", wonderful_substrings(String::from("aabbc"))); // 12
}<|fim_prefix|>// repo: fredyw/... | code_fim | medium | {
"lang": "rust",
"repo": "fredyw/leetcode",
"path": "/src/main/rust/src/bin/problem1915.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fredyw/leetcode path: /src/main/rust/src/bin/problem1915.rs
// https://leetcode.com/problems/number-of-wonderful-substrings/
pub fn wonderful_substrings(word: String) -> i64 {
let mut answer = 0;
let mut counts = vec![0; 1024]; // 1111111111 = 1023
counts[0] = 1;
let chars: Vec<c... | code_fim | medium | {
"lang": "rust",
"repo": "fredyw/leetcode",
"path": "/src/main/rust/src/bin/problem1915.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wevanscfi/advent-of-code-2019 path: /src/day2.rs
use std::env;
use std::fs;
struct Config {
args: Vec<String>,
command: String,
}
fn parse_config() -> Config {
let mut args: Vec<String> = env::args().collect();
let command = args[1].clone();
args.drain(0..2);
Config { args,... | code_fim | hard | {
"lang": "rust",
"repo": "wevanscfi/advent-of-code-2019",
"path": "/src/day2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn first_task() {
let mut program = IntCodeProgram::from_file("inputs/day2.txt".to_string());
assert_eq!(program.noun(12).verb(2).run(),4330636);
}
#[test]
fn second_task() {
let mut program = IntCodeProgram::from_file("inputs/day2.txt".to_string())... | code_fim | hard | {
"lang": "rust",
"repo": "wevanscfi/advent-of-code-2019",
"path": "/src/day2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let state = vec![1,0,0,0,99];
let mut program = IntCodeProgram::new(state);
assert_eq!(program.run(),2);
}
#[test]
fn first_task() {
let mut program = IntCodeProgram::from_file("inputs/day2.txt".to_string());
assert_eq!(program.noun(12).verb(2).run(),43... | code_fim | hard | {
"lang": "rust",
"repo": "wevanscfi/advent-of-code-2019",
"path": "/src/day2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acshi/jlrs path: /examples/generator_tasks/src/main.rs
use jlrs::prelude::*;
use std::time::Duration;
// This struct contains the data our task will need. This struct must implement `Send`, `Sync`,
// and contain no borrowed data.
struct AccumulatorTask {
init_value: f64,
}
// `Implement `... | code_fim | hard | {
"lang": "rust",
"repo": "acshi/jlrs",
"path": "/examples/generator_tasks/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create a new AccumulatorTask, if AccumulatorTask::init completes successfully a handle to
// the generator is returned.
let generator = julia
.try_generator(AccumulatorTask { init_value: 5.0 })
.expect("AccumulatorTask::init failed");
// Call the generator twice. Becaus... | code_fim | hard | {
"lang": "rust",
"repo": "acshi/jlrs",
"path": "/examples/generator_tasks/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> func.call1(os, init_v)
})?
.into_jlrs_result()
}
}
// Call the generator once. Note that while the state can be mutated, you can't replace any
// Julia data that it contains with newly allocated data because it's called in a nested
... | code_fim | hard | {
"lang": "rust",
"repo": "acshi/jlrs",
"path": "/examples/generator_tasks/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // backwards from the tokio one because woo hoo yay
let (mut writer, mut reader) = ws_stream.split();
//let mut rx = tx.subscribe();
tokio::spawn(async move {
// In a loop, read data from the socket and write the data back.
loop {
let read_result = reader.next(... | code_fim | hard | {
"lang": "rust",
"repo": "lahwran/milkshell",
"path": "/src/ws.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut connector = broadcast_replay::launch_broadcasters(single);
// Next up we create a TCP listener which will listen for incoming
// connections. This TCP listener is bound to the address we determined
// above and must be associated with an event loop.
let mut listener = TcpListe... | code_fim | hard | {
"lang": "rust",
"repo": "lahwran/milkshell",
"path": "/src/ws.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lahwran/milkshell path: /src/ws.rs
use std::error::Error;
use tokio::net::{TcpListener, TcpStream};
use tokio::sync::mpsc;
// have to use this particular split function on tcp sockets - tcpstream.split() doesn't work
use futures::{SinkExt, StreamExt};
use crate::broadcast_replay;
use crate::m... | code_fim | hard | {
"lang": "rust",
"repo": "lahwran/milkshell",
"path": "/src/ws.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tommilligan/decadog path: /decadog_core/src/github/request.rs
use lazy_static::lazy_static;
use regex::Regex;
use reqwest::blocking::{RequestBuilder, Response};
use reqwest::header::LINK;
use serde::de::DeserializeOwned;
use url::Url;
use crate::error::Error;
lazy_static! {
static ref RX_L... | code_fim | hard | {
"lang": "rust",
"repo": "tommilligan/decadog",
"path": "/decadog_core/src/github/request.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ResponseExt for Response {
fn into_github<T>(self) -> Result<T, Error>
where
Self: Sized,
T: DeserializeOwned,
{
let status = self.status();
if status.is_success() {
Ok(self.json()?)
} else if status.is_client_error() {
Err(E... | code_fim | hard | {
"lang": "rust",
"repo": "tommilligan/decadog",
"path": "/decadog_core/src/github/request.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO(tommilligan) Find an actual Link header parsing implementation
match self.headers().get(LINK) {
None => Ok(None),
Some(header_value) => {
match RX_LINK_NEXT.captures(header_value.to_str().map_err(|_| Error::Unknown {
descr... | code_fim | hard | {
"lang": "rust",
"repo": "tommilligan/decadog",
"path": "/decadog_core/src/github/request.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(::std::mem::size_of::<bpf_attr__bindgen_ty_2>() , 32usize ,
concat ! ( "Size of: " , stringify ! ( bpf_attr__bindgen_ty_2 )
));
assert_eq! (::std::mem::align_of::<bpf_attr__bindgen_ty_2>() , 8usize ,
concat ! (
"Alignment of ... | code_fim | hard | {
"lang": "rust",
"repo": "badboy/libbpf-rs",
"path": "/libbpf-sys/src/bpf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: badboy/libbpf-rs path: /libbpf-sys/src/bpf.rs
ize } , 12usize , concat ! (
"Alignment of field: " , stringify ! ( bpf_attr__bindgen_ty_1
) , "::" , stringify ! ( max_entries ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const bpf_attr__bindgen_ty_1... | code_fim | hard | {
"lang": "rust",
"repo": "badboy/libbpf-rs",
"path": "/libbpf-sys/src/bpf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: badboy/libbpf-rs path: /libbpf-sys/src/bpf.rs
() , 8usize , concat !
( "Alignment of " , stringify ! ( __kernel_fd_set ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const __kernel_fd_set ) ) . fds_bits as * const
_ as usize } , 0usize , concat ! (
... | code_fim | hard | {
"lang": "rust",
"repo": "badboy/libbpf-rs",
"path": "/libbpf-sys/src/bpf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: funn1est/leetcode-rust path: /src/solutions/n9_palindrome_number/mod.rs
/// https://leetcode.com/problems/palindrome-number/
///
/// https://leetcode-cn.com/problems/palindrome-number/
pub struct Solution {}
impl Solution {
pub fn is_palindrome(x: i32) -> bool {
#[allow(unused_doc_c... | code_fim | medium | {
"lang": "rust",
"repo": "funn1est/leetcode-rust",
"path": "/src/solutions/n9_palindrome_number/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_is_palindrome() {
assert_eq!(Solution::is_palindrome(121), true);
assert_eq!(Solution::is_palindrome(-121), false);
assert_eq!(Solution::is_palindrome(10), false);
}
}<|fim_prefix|>// repo: funn1est/leetcode-rust path: /src/solutions/n9_palindrome_numbe... | code_fim | medium | {
"lang": "rust",
"repo": "funn1est/leetcode-rust",
"path": "/src/solutions/n9_palindrome_number/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Solution::is_palindrome(121), true);
assert_eq!(Solution::is_palindrome(-121), false);
assert_eq!(Solution::is_palindrome(10), false);
}
}<|fim_prefix|>// repo: funn1est/leetcode-rust path: /src/solutions/n9_palindrome_number/mod.rs
/// https://leetcode.com/problems... | code_fim | hard | {
"lang": "rust",
"repo": "funn1est/leetcode-rust",
"path": "/src/solutions/n9_palindrome_number/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn mute(&self) -> Result<bool> {
let mut mute = 0;
fmod_call!(FMOD_Studio_Bus_GetMute, self.0, &mut mute => mute % 2 != 0)
}
pub fn set_mute(&mut self, mute: bool) -> Result<()> {
fmod_call!(FMOD_Studio_Bus_SetMute, self.0, mute as i32 => ())
}
pub fn stop... | code_fim | hard | {
"lang": "rust",
"repo": "igaryhe/fmod-rs",
"path": "/src/bus.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: igaryhe/fmod-rs path: /src/bus.rs
use crate::{fmod_call, MemoryUsage, ChannelGroup, GUID};
use anyhow::{anyhow, Result};
use core::ptr;
use std::ffi::CString;
pub struct Bus(*mut sys::FMOD_STUDIO_BUS);
impl Bus {
pub unsafe fn new(bus: *mut sys::FMOD_STUDIO_BUS) -> Self {
Self(bus)... | code_fim | hard | {
"lang": "rust",
"repo": "igaryhe/fmod-rs",
"path": "/src/bus.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn volume(&self) -> Result<(f32, f32)> {
let mut volume = 0.0;
let mut final_volume = 0.0;
fmod_call!(FMOD_Studio_Bus_GetVolume, self.0, &mut volume, &mut final_volume => (volume, final_volume))
}
pub fn set_volume(&mut self, volume: f32) -> Result<()> {
fm... | code_fim | hard | {
"lang": "rust",
"repo": "igaryhe/fmod-rs",
"path": "/src/bus.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: inakleinbottle/teach path: /src/lib.rs
use failure::Error;
pub type TeachResult<T> = Result<T, Error>;
<|fim_suffix|>pub use course::Course;<|fim_middle|>pub mod config;
pub mod course;
pub mod course_items;
pub mod latexdoc;
pub mod makefile;
pub mod preview;
| code_fim | medium | {
"lang": "rust",
"repo": "inakleinbottle/teach",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod config;
pub mod course;
pub mod course_items;
pub mod latexdoc;
pub mod makefile;
pub mod preview;
pub use course::Course;<|fim_prefix|>// repo: inakleinbottle/teach path: /src/lib.rs
use failure::Error;
<|fim_middle|>pub type TeachResult<T> = Result<T, Error>;
| code_fim | easy | {
"lang": "rust",
"repo": "inakleinbottle/teach",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AcrylicShrimp/piped path: /src/runtime/builtins/functions/function_get.rs
use super::super::super::value::ValueType;
define_function!(Get(_execution, argument_vec) => {
if argument_vec.len() != 2 {
panic!("2 arguments required, got {}.", argument_vec.len())
}
if let Value::Array(array) = ... | code_fim | hard | {
"lang": "rust",
"repo": "AcrylicShrimp/piped",
"path": "/src/runtime/builtins/functions/function_get.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match dict.get(&key) {
Some(value) => value.clone(),
None => panic!("Unable to find key \"{}\".", key)
}
} else {
panic!("Type mismatch; only {:#?} or {:#?} can be used here.", ValueType::Array, ValueType::Dictionary)
}
});<|fim_prefix|>// repo: AcrylicShrimp/piped path: /src/runtime/built... | code_fim | hard | {
"lang": "rust",
"repo": "AcrylicShrimp/piped",
"path": "/src/runtime/builtins/functions/function_get.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crate-ci/typos path: /crates/typos-vars/tests/codegen.rs
use std::collections::BTreeMap;
use std::collections::HashSet;
use std::io::Write;
#[test]
fn codegen() {
let mut content = vec![];
generate_variations(&mut content);
let content = String::from_utf8(content).unwrap();
let... | code_fim | hard | {
"lang": "rust",
"repo": "crate-ci/typos",
"path": "/crates/typos-vars/tests/codegen.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> varcon::VARCON
.iter()
.flat_map(|c| c.entries.iter())
.filter(|e| {
e.variants
.iter()
.all(|v| typos::tokens::Word::new(v.word, 0).is_ok())
})
.map(|e| {
let mut e = e.into_owned();
for varian... | code_fim | hard | {
"lang": "rust",
"repo": "crate-ci/typos",
"path": "/crates/typos-vars/tests/codegen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let no_invalid = entry_sets.values().all(|data| !is_always_invalid(data));
writeln!(file).unwrap();
writeln!(file, "pub const NO_INVALID: bool = {:?};", no_invalid,).unwrap();
writeln!(file).unwrap();
for (symbol, entry) in entries.iter() {
if !referenced_symbols.contains(symb... | code_fim | hard | {
"lang": "rust",
"repo": "crate-ci/typos",
"path": "/crates/typos-vars/tests/codegen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Implemented
pub static STOPWORDS_MAI: Lazy<HashSet<&'static str>> = Lazy::new(HashSet::new);<|fim_prefix|>// repo: qdequele/toku path: /src/stopwords/mai.rs
use once_cell::sync::Lazy;
use std::collectio<|fim_middle|>ns::HashSet;
/// मैथिली (Maithili) - Not Yet | code_fim | easy | {
"lang": "rust",
"repo": "qdequele/toku",
"path": "/src/stopwords/mai.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qdequele/toku path: /src/stopwords/mai.rs
use once_cell::sync::Lazy;
use std::collections::HashSet;
/// मैथिली (Maithili) - Not Yet <|fim_suffix|>hSet<&'static str>> = Lazy::new(HashSet::new);<|fim_middle|>Implemented
pub static STOPWORDS_MAI: Lazy<Has | code_fim | easy | {
"lang": "rust",
"repo": "qdequele/toku",
"path": "/src/stopwords/mai.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qdequele/toku path: /src/stopwords/mai.rs
use once_cell::sync::Lazy;
use std::collectio<|fim_suffix|>hSet<&'static str>> = Lazy::new(HashSet::new);<|fim_middle|>ns::HashSet;
/// मैथिली (Maithili) - Not Yet Implemented
pub static STOPWORDS_MAI: Lazy<Has | code_fim | medium | {
"lang": "rust",
"repo": "qdequele/toku",
"path": "/src/stopwords/mai.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ConnectionState::Resetting(initial) => {
// Tell remote host to reset
let pkt: ResetPacket = Default::default();
let w = write_packet(self, &mut buf, struct_as_slice(&pkt),
PacketType::Reset)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "duzhanyuan/ossuary",
"path": "/src/handshake.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // This is the first encrypted message, so the nonce has not changed yet
let mut sign_data = [0u8; KEY_LEN + NONCE_LEN + CHALLENGE_LEN];
sign_data[0..KEY_LEN].copy_from_slice(self.remote... | code_fim | hard | {
"lang": "rust",
"repo": "duzhanyuan/ossuary",
"path": "/src/handshake.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.