text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> // Save the new index
index.save(repo_path);
// Update HEAD
refs::update(
repo_path,
&String::from("HEAD"),
&format!("ref: refs/heads/{}", branch),
false,
)?;
Ok(())
}
pub fn run(args: &ArgMatches) -> Result<(), Box<dyn Error>> {
let repo_path ... | code_fim | hard | {
"lang": "rust",
"repo": "flomonster/my-git",
"path": "/src/cmd/switch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> static DROPS: AtomicUsize = AtomicUsize::new(0);
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
DROPS.fetch_add(1, Ordering::SeqCst);
}
}
let m = AtomicOptionRef::<Foo>::new();
m.swap(Foo);
m.swap(Foo... | code_fim | hard | {
"lang": "rust",
"repo": "mehcode/atomic-ref2-rs",
"path": "/src/option_ref.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mehcode/atomic-ref2-rs path: /src/option_ref.rs
use super::spinlock::SpinRwLock;
use super::IntoOptionArc;
use std::mem;
use std::ptr::null_mut;
use std::sync::atomic::{AtomicPtr, Ordering};
use std::sync::Arc;
/// An atomic reference that may be updated atomically.
pub struct AtomicOptionRef<T... | code_fim | hard | {
"lang": "rust",
"repo": "mehcode/atomic-ref2-rs",
"path": "/src/option_ref.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: netthier/stm32-gameboy path: /src/peripherals.rs
use stm32f3_discovery::stm32f3xx_hal::{pac, prelude::*, serial::Serial};
<|fim_suffix|> let mut gpioc = dp.GPIOC.split(&mut rcc.ahb);
let clocks = rcc
.cfgr
.use_hse(8u32.mhz())
.sysclk(72u32.mhz())
.pclk1(... | code_fim | medium | {
"lang": "rust",
"repo": "netthier/stm32-gameboy",
"path": "/src/peripherals.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut flash = dp.FLASH.constrain();
let mut rcc = dp.RCC.constrain();
let mut gpioc = dp.GPIOC.split(&mut rcc.ahb);
let clocks = rcc
.cfgr
.use_hse(8u32.mhz())
.sysclk(72u32.mhz())
.pclk1(24u32.mhz())
.freeze(&mut flash.acr);
}<|fim_prefix|>// re... | code_fim | medium | {
"lang": "rust",
"repo": "netthier/stm32-gameboy",
"path": "/src/peripherals.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let clocks = rcc
.cfgr
.use_hse(8u32.mhz())
.sysclk(72u32.mhz())
.pclk1(24u32.mhz())
.freeze(&mut flash.acr);
}<|fim_prefix|>// repo: netthier/stm32-gameboy path: /src/peripherals.rs
use stm32f3_discovery::stm32f3xx_hal::{pac, prelude::*, serial::Serial};
pub ... | code_fim | easy | {
"lang": "rust",
"repo": "netthier/stm32-gameboy",
"path": "/src/peripherals.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whyswhy/delay-timer path: /src/prelude.rs
//! A "prelude" for users of the `delay-timer` crate.
//!
//! This prelude is similar to the standard library's prelude in that you'll
//! almost always want to import its entire contents, but unlike the standard
//! library's prelude you'll have to do s... | code_fim | hard | {
"lang": "rust",
"repo": "whyswhy/delay-timer",
"path": "/src/prelude.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) use crate::utils::parse::shell_command::{ChildGuard, ChildGuardList, ChildUnify};
pub(crate) use dashmap::DashMap;
#[allow(unused_imports)]
pub(crate) use log::{error, info};
pub(crate) use smol::channel::{Receiver as AsyncReceiver, Sender as AsyncSender};
pub(crate) use smol::future::yield_now... | code_fim | hard | {
"lang": "rust",
"repo": "whyswhy/delay-timer",
"path": "/src/prelude.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LastLeaf/maomi path: /maomi/src/error.rs
//! The error utilities.
/// An framework error.
#[derive(Debug)]
pub enum Error {
/// A custom error.
///
/// Generally refers to errors generated by other crates.
Custom(Box<dyn std::error::Error>),
/// The operation is invalid befo... | code_fim | medium | {
"lang": "rust",
"repo": "LastLeaf/maomi",
"path": "/maomi/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Error::Custom(err) => {
write!(f, "{}", err)?;
}
Error::TreeNotCreated => {
write!(f, "Component template has not been initialized")?;
}
Error::TreeNodeTypeWrong => {
write!(f, ... | code_fim | medium | {
"lang": "rust",
"repo": "LastLeaf/maomi",
"path": "/maomi/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl MyAdd for u32 {
type Output = u32;
fn my_add(self, rhs: Self) -> Self::Output {
self + rhs
}
}
fn test3() {
let (a, b) = (8u32, 90u32);
println!("{}",a.my_add(b));
}
#[derive(Debug)]
struct Point{
x: i32,
y: i32,
}
impl Add for Point {
type Output = Point... | code_fim | hard | {
"lang": "rust",
"repo": "dollarkillerx/Learn-RUST-again",
"path": "/day2_1/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dollarkillerx/Learn-RUST-again path: /day2_1/src/main.rs
use std::ops::Add;
fn main() {
let mut c = [1, 2, 3, 4, 5, 6];
mdf(&mut c);
println!("{:?}", c);
cp(&mut c);
println!("{:?}", c);
println!("=================================");
test1();
test2();
test3(... | code_fim | hard | {
"lang": "rust",
"repo": "dollarkillerx/Learn-RUST-again",
"path": "/day2_1/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Config {
pub fn read_config(config : &str) -> Result<Config> {
let config_str = fs::read_to_string(config).unwrap();
let config : Config = serde_json::from_str(&config_str)?;
Ok(config)
}
}<|fim_prefix|>// repo: GoX1337/oracle-cli-rs path: /src/config.rs
use std::fs;
... | code_fim | medium | {
"lang": "rust",
"repo": "GoX1337/oracle-cli-rs",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GoX1337/oracle-cli-rs path: /src/config.rs
use std::fs;
use serde::{Deserialize, Serialize};
use serde_json::Result;
<|fim_suffix|>impl Config {
pub fn read_config(config : &str) -> Result<Config> {
let config_str = fs::read_to_string(config).unwrap();
let config : Config = ... | code_fim | medium | {
"lang": "rust",
"repo": "GoX1337/oracle-cli-rs",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let effect: Box<dyn Effect> = Box::new(SpecificEffect::new(2));
let json = serde_json::to_string(&effect).unwrap();
let parsed: Box<dyn Effect> = serde_json::from_str(&json).unwrap();
println!("{} / {}", effect.appliable(&object), json);
assert_eq!(effect.appliable(&object), parsed.app... | code_fim | hard | {
"lang": "rust",
"repo": "n-ari/dyntrait-test",
"path": "/app/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let effect: Box<dyn Effect> = Box::new(SpecificEffect::new(3));
let json = serde_json::to_string(&effect).unwrap();
let parsed: Box<dyn Effect> = serde_json::from_str(&json).unwrap();
println!("{} / {}", effect.appliable(&object), json);
assert_eq!(effect.appliable(&object), parsed.app... | code_fim | hard | {
"lang": "rust",
"repo": "n-ari/dyntrait-test",
"path": "/app/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: n-ari/dyntrait-test path: /app/src/main.rs
use base::{Effect, ForAllEffect, Object};
use ext::SpecificEffect;
fn main() {
let object = Object::new(3);
// normal box
let effect = Box::new(ForAllEffect::new());
let json = serde_json::to_string(&effect).unwrap();
println!("{} ... | code_fim | hard | {
"lang": "rust",
"repo": "n-ari/dyntrait-test",
"path": "/app/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erenoku/Figment path: /src/providers/mod.rs
//! Built-in [`Provider`](crate::Provider) implementations for common sources.
//!
//! The [top-level docs](crate#built-in-providers) contain a list and
//! description of each provider.
<|fim_suffix|>#[cfg(feature = "env")] mod env;
#[cfg(feature = "... | code_fim | easy | {
"lang": "rust",
"repo": "erenoku/Figment",
"path": "/src/providers/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::serialized::Serialized;
pub use self::data::*;<|fim_prefix|>// repo: erenoku/Figment path: /src/providers/mod.rs
//! Built-in [`Provider`](crate::Provider) implementations for common sources.
//!
//! The [top-level docs](crate#built-in-providers) contain a list and
//! description of each p... | code_fim | medium | {
"lang": "rust",
"repo": "erenoku/Figment",
"path": "/src/providers/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ko1N/memflow-coredump path: /src/native/x86.rs
use super::full_memory_dump::*;
use super::*;
use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
use std::mem::size_of;
use std::mem::MaybeUninit;
use dataview::Pod;
use log::info;
use memflow::*;
use memflow_derive::*;
pub const DUMP_VALID_... | code_fim | hard | {
"lang": "rust",
"repo": "ko1N/memflow-coredump",
"path": "/src/native/x86.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(size_of::<PhysicalMemoryRun<u32>>(), 0x8);
assert_eq!(size_of::<PhysicalMemoryDescriptor<u32>>(), 0x108);
assert_eq!(size_of::<CoreDumpHeader32>(), 0x1000);
}
#[test]
fn test_struct_members_x86() {
let header = CoreDumpHeader32::uninit();
ass... | code_fim | hard | {
"lang": "rust",
"repo": "ko1N/memflow-coredump",
"path": "/src/native/x86.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if method.initialized && method.name == fct.name && method.is_static == fct.is_static {
let method_name = vm.interner.str(method.name).to_string();
let msg = SemError::MethodExists(method_name, method.pos);
vm.diag.lock().report(fct.file, fct.ast.pos, msg);
... | code_fim | hard | {
"lang": "rust",
"repo": "mrnugget/dora",
"path": "/dora/src/semck/fctdefck.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrnugget/dora path: /dora/src/semck/fctdefck.rs
use std::collections::HashSet;
use crate::error::msg::SemError;
use crate::semck;
use crate::sym::TypeSym;
use crate::ty::BuiltinType;
use crate::vm::{self, Fct, FctId, FctParent, FctSrc, VM};
use dora_parser::ast::visit::*;
use dora_parser::ast::... | code_fim | hard | {
"lang": "rust",
"repo": "mrnugget/dora",
"path": "/dora/src/semck/fctdefck.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn abstract_method_in_non_abstract_class() {
err(
"class A { @abstract fun foo(); }",
pos(1, 21),
SemError::AbstractMethodNotInAbstractClass,
);
}
#[test]
fn abstract_method_with_implementation() {
err(
"@... | code_fim | hard | {
"lang": "rust",
"repo": "mrnugget/dora",
"path": "/dora/src/semck/fctdefck.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s = Shape::new(vec![]);
let s_clone = s.clone();
drop(s);
assert_eq!(s_clone.rank, 0);
assert_eq!(s_clone.dim, vec![]);
let s = Shape::new(vec![1]);
let s_clone = s.clone();
drop(s);
assert_eq!(s_clone.rank, 1);
assert_eq!(s_clone.dim, vec![1]);
}<|fim_pref... | code_fim | hard | {
"lang": "rust",
"repo": "cmpark0126/wicwiu-rust",
"path": "/tests/shape.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cmpark0126/wicwiu-rust path: /tests/shape.rs
use wicwiu::shape::Shape;
#[test]
fn shape_define() {
let s = Shape::new(vec![]);
assert_eq!(s.rank, 0);
assert_eq!(s.dim, vec![]);
let s = Shape::new(vec![1]);
assert_eq!(s.rank, 1);
assert_eq!(s.dim, vec![1]);
<|fim_suffix... | code_fim | medium | {
"lang": "rust",
"repo": "cmpark0126/wicwiu-rust",
"path": "/tests/shape.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sgaliamov/ergo-balance path: /src/bin/genetic_keyboard/main.rs
mod behaviour;
mod keyboard;
use behaviour::Behaviour;
use ed_balance::{run, CliSettings};
use keyboard::{Keyboard, Mutation};
use std::process;
use structopt::StructOpt;
<|fim_suffix|> let args = CliSettings::from_args();
i... | code_fim | medium | {
"lang": "rust",
"repo": "sgaliamov/ergo-balance",
"path": "/src/bin/genetic_keyboard/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args = CliSettings::from_args();
if let Err(e) = run::<Mutation, Keyboard, Behaviour>(args) {
eprintln!("Calculations failed: {:#?}", e);
process::exit(1);
}
}<|fim_prefix|>// repo: sgaliamov/ergo-balance path: /src/bin/genetic_keyboard/main.rs
mod behaviour;
mod keyboard;... | code_fim | medium | {
"lang": "rust",
"repo": "sgaliamov/ergo-balance",
"path": "/src/bin/genetic_keyboard/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: decadevvv/influxdb_iox path: /observability_deps/src/lib.rs
//! This crate exists to coordinate versions of `opentelemetry`, `tracing`,
//! `prometheus` and related crates so that we can manage their updates in a
//! single crate.
// Export these crates publicly so we can have a single referenc... | code_fim | medium | {
"lang": "rust",
"repo": "decadevvv/influxdb_iox",
"path": "/observability_deps/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>v_logger;
pub use opentelemetry;
pub use opentelemetry_jaeger;
pub use opentelemetry_otlp;
pub use opentelemetry_prometheus;
pub use prometheus;
pub use tracing;
pub use tracing::instrument;
pub use tracing_opentelemetry;
pub use tracing_subscriber;<|fim_prefix|>// repo: decadevvv/influxdb_iox path: /obs... | code_fim | medium | {
"lang": "rust",
"repo": "decadevvv/influxdb_iox",
"path": "/observability_deps/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: garrensmith/mango_smoothie path: /src/errors.rs
use std::fmt;
use hyper::Error as HyperError;
use hyper::error::ParseError;
use std::error::Error as StdError;
use std::io;
use std::collections::HashMap;
use serde_json;
use serde_json::Error as JsonError;
use self::Error::{Json, Http, Io, Query,... | code_fim | hard | {
"lang": "rust",
"repo": "garrensmith/mango_smoothie",
"path": "/src/errors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let str = "{\"error\":\"not_found\",\"reason\":\"Database does not exist.\"}";
match Error::from_couch(str) {
Query { ref error, .. } => assert_eq!(error, "not_found"),
_ => panic!("I was expecting query error"),
}
}
#[test]
fn from_couch_works... | code_fim | hard | {
"lang": "rust",
"repo": "garrensmith/mango_smoothie",
"path": "/src/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
#[test]
fn from_couch_works_with_different_hashmap_values() {
let str = "{\"oops\":\"not_found\",\"what_happened\":\"Database does not exist.\"}";
match Error::from_couch(str) {
Query { ref error, ref description } => {
assert_eq!(error,... | code_fim | hard | {
"lang": "rust",
"repo": "garrensmith/mango_smoothie",
"path": "/src/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fanszoro/ts7200 path: /src/devices/timer.rs
use std::thread::{self, JoinHandle};
use std::time::{Duration, Instant};
use crossbeam_channel as chan;
use crate::devices::{Device, Probe};
use crate::memory::{MemException::*, MemResult, Memory};
use super::vic::Interrupt;
#[derive(Clone, Copy, D... | code_fim | hard | {
"lang": "rust",
"repo": "fanszoro/ts7200",
"path": "/src/devices/timer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn w32(&mut self, offset: u32, val: u32) -> MemResult<()> {
self.update_regs()?;
match offset {
0x00 => {
// "The Load register should not be written after the Timer is enabled because
// this causes the Timer Value register to be updated wi... | code_fim | hard | {
"lang": "rust",
"repo": "fanszoro/ts7200",
"path": "/src/devices/timer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> interrupt_bus: chan::Sender<(Interrupt, bool)>,
interrupt: Interrupt,
interrupter_tx: chan::Sender<InterrupterMsg>,
}
impl Timer {
/// Create a new Timer
pub fn new(
label: &'static str,
interrupt_bus: chan::Sender<(Interrupt, bool)>,
interrupt: Interrupt,
... | code_fim | hard | {
"lang": "rust",
"repo": "fanszoro/ts7200",
"path": "/src/devices/timer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn bind(addr: SocketAddr) -> io::Result<net::TcpListener> {
init();
new_socket(addr, SOCK_STREAM).and_then(|socket| {
let (raw_addr, raw_addr_length) = socket_addr(&addr);
syscall!(
win_bind(socket, raw_addr, raw_addr_length,),
PartialEq::eq,
... | code_fim | hard | {
"lang": "rust",
"repo": "peterjoel/mio",
"path": "/src/sys/windows/tcp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peterjoel/mio path: /src/sys/windows/tcp.rs
use std::io;
use std::net::{self, SocketAddr};
use std::os::windows::io::FromRawSocket;
use std::os::windows::raw::SOCKET as StdSocket; // winapi uses usize, stdlib uses u32/u64.
use winapi::um::winsock2::{
bind as win_bind, closesocket, connect a... | code_fim | hard | {
"lang": "rust",
"repo": "peterjoel/mio",
"path": "/src/sys/windows/tcp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Devolutions/picky-rs path: /picky-asn1-x509/src/version.rs
use serde::{de, ser, Deserialize, Serialize};
use std::fmt;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[repr(u8)]
pub enum Version {
V1 = 0x00,
V2 = 0x01,
V3 = 0x02,
}
impl Default for Version {
fn default() -> Self ... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/picky-rs",
"path": "/picky-asn1-x509/src/version.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(formatter, "a valid version number")
}
fn visit_u8<E>(self, v: u8) -> Result<Self::Value, E>
where
E: de::Error,
{
let version = Version::from_u8(v).ok_or_else(|| {
E::invalid_value(... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/picky-rs",
"path": "/picky-asn1-x509/src/version.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let addr = ([127, 0, 0, 1], 1339).into();
let server = Server::bind(&addr)
.serve(|| service_fn(proxy))
.map_err(|e| eprintln!("server error: {}", e));
println!("Running proxy on :1339");
hyper::rt::run(server);
}<|fim_prefix|>// repo: james-proxy/james-http-proxy path: ... | code_fim | hard | {
"lang": "rust",
"repo": "james-proxy/james-http-proxy",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: james-proxy/james-http-proxy path: /src/main.rs
extern crate futures;
extern crate hyper;
use hyper::Body;
use hyper::Client;
use hyper::Request;
use hyper::Response;
use hyper::rt::Future;
use hyper::Server;
use hyper::service::service_fn;
type BoxFut = Box<Future<Item=Response<Body>, Error=h... | code_fim | hard | {
"lang": "rust",
"repo": "james-proxy/james-http-proxy",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let server = Server::bind(&addr)
.serve(|| service_fn(proxy))
.map_err(|e| eprintln!("server error: {}", e));
println!("Running proxy on :1339");
hyper::rt::run(server);
}<|fim_prefix|>// repo: james-proxy/james-http-proxy path: /src/main.rs
extern crate futures;
extern crate... | code_fim | hard | {
"lang": "rust",
"repo": "james-proxy/james-http-proxy",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmstick/debrepbuild path: /src/sources.rs
use std::{
fs::File,
io::{self, Read},
path::{Path, PathBuf},
};
use toml::{self, de};
#[derive(Debug, Fail)]
pub enum ParsingError {
#[fail(display = "error reading '{}': {}", file, why)]
File { file: &'static str, why: io::Error }... | code_fim | medium | {
"lang": "rust",
"repo": "mmstick/debrepbuild",
"path": "/src/sources.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize)]
pub struct Source {
pub name: String,
pub version: String,
pub url: String,
}
impl Direct {
pub fn file_name(&self) -> String {
[&self.name, "_", &self.version, "_", &self.arch, ".deb"].concat()
}
pub fn destination(&self) -> PathBuf {
... | code_fim | medium | {
"lang": "rust",
"repo": "mmstick/debrepbuild",
"path": "/src/sources.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// NOTE: This was stabilized in Rust 1.26.0
fn read<P: AsRef<Path>>(path: P) -> io::Result<String> {
File::open(path.as_ref()).and_then(|mut file| {
let mut buffer =
String::with_capacity(file.metadata().map(|x| x.len() as usize).unwrap_or(0));
file.read_to_string(&mut buff... | code_fim | medium | {
"lang": "rust",
"repo": "mmstick/debrepbuild",
"path": "/src/sources.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxjacobson/advent-of-code-2016 path: /day-04/src/room.rs
extern crate regex;
use self::regex::Regex;
use std::collections::HashMap;
use std::cmp::Ordering;
#[derive(Debug)]
pub struct Room {
encrypted_name: String,
pub sector_id: u32,
checksum: String,
}
impl Room {
pub fn n... | code_fim | hard | {
"lang": "rust",
"repo": "maxjacobson/advent-of-code-2016",
"path": "/day-04/src/room.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let room3 = Room::new(String::from("not-a-real-room-404[oarel]"));
assert!(room3.real());
let room4 = Room::new(String::from("totally-real-room-200[decoy]"));
assert!(!room4.real());
}
#[test]
fn decrypt() {
let room = Room::new(String::from("qzmt-zixmtkozy-ivhz-343[decoy]"));
as... | code_fim | hard | {
"lang": "rust",
"repo": "maxjacobson/advent-of-code-2016",
"path": "/day-04/src/room.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: donutsonhudson/octavo path: /src/digest/sha3.rs
00000000080,
0x000000000000800a,
0x800000008000000a,
0x8000000080008081,
0x8000000000008080,
... | code_fim | hard | {
"lang": "rust",
"repo": "donutsonhudson/octavo",
"path": "/src/digest/sha3.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn permutation(&mut self) {
for round in &ROUND_CONSTS {
self.theta();
self.rho();
self.pi();
self.chi();
// iota
self.hash[0] ^= *round;
}
}
fn process(&mut self, data: &[u8]) {
let max = self.bl... | code_fim | hard | {
"lang": "rust",
"repo": "donutsonhudson/octavo",
"path": "/src/digest/sha3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: donutsonhudson/octavo path: /src/digest/sha3.rs
08080,
0x0000000080000001,
0x8000000080008008];
const SHIFTS: [u32; 25] = [0, 1, 62, 28, 27, 36, 44, 6, 55, 20, 3, 10, 43, 25, 39, 41, 45, 15, 21,
8, 18, ... | code_fim | hard | {
"lang": "rust",
"repo": "donutsonhudson/octavo",
"path": "/src/digest/sha3.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsoutlined/social/icon_emoji_events.rs
pub struct IconEmojiEvents {
props: crate::Props,
}
impl yew::Component for IconEmojiEvents {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew:... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsoutlined/social/icon_emoji_events.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/macros/macro-shadowing-relaxed.rs
// build-pass (FIXME(62277): could be check-pass?)
// aux-build:macro-in-other-crate.rs
#![feature(decl_macro)]
<|fim_suffix|> fn inner() {
// Inner
macro m() {}
macro_rules! from_pr... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/macros/macro-shadowing-relaxed.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustCrypto/utils path: /cmov/tests/lib.rs
mod u8 {
use cmov::{Cmov, CmovEq};
pub const U8_A: u8 = 0x11;
pub const U8_B: u8 = 0x22;
#[test]
fn cmovz_works() {
let mut n = U8_A;
for cond in 1..0xFF {
n.cmovz(&U8_B, cond);
assert_eq!(n,... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/utils",
"path": "/cmov/tests/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> n.cmovz(&U128_B, 0);
assert_eq!(n, U128_B);
}
#[test]
fn cmovnz_works() {
let mut n = U128_A;
n.cmovnz(&U128_B, 0);
assert_eq!(n, U128_A);
for cond in 1..0xFF {
let mut n = U128_A;
n.cmovnz(&U128_B, cond);
as... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/utils",
"path": "/cmov/tests/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn search(queen_count: i8, field: &mut Vec<i32>, curr_col: i32,
curr_row: i32) -> i32 {
if curr_col >= field.len() as i32 && curr_row >= 7 {
return -1;
}
if queen_count > NUM_OF_QUEENS - 1 {
return 0;
}
if field[curr_col as usize] != -1 {
return searc... | code_fim | medium | {
"lang": "rust",
"repo": "rettetdemdativ/POS_HTBLA",
"path": "/algorithms/recursion/8queenspuzzle-bak/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe fn find_comb_8queens(c: i8) {
let mut field = &mut vec![-1; 10];
let res = search(c, field, 0, 0);
if res == -1 {
return;
} else if res == 0 {
count = count + 1;
}
find_comb_8queens(c+1);
}
fn main() {
/*search(field, 0, 0);
unsafe {
println... | code_fim | hard | {
"lang": "rust",
"repo": "rettetdemdativ/POS_HTBLA",
"path": "/algorithms/recursion/8queenspuzzle-bak/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rettetdemdativ/POS_HTBLA path: /algorithms/recursion/8queenspuzzle-bak/src/main.rs
// Michael Koeppl 4AHIF
// Queens puzzle
// 13 June 2016
//
// 12 fundamentally different solutions
// 92 distinct solutions
static mut count: i32 = 0;
const NUM_OF_QUEENS: i8 = 8;
fn insert(field: &mut Vec<i32>... | code_fim | hard | {
"lang": "rust",
"repo": "rettetdemdativ/POS_HTBLA",
"path": "/algorithms/recursion/8queenspuzzle-bak/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/ttf-parser-0.10.1/src/tables/maxp.rs
// https://docs.microsoft.com/en-us/typography/opentype/spec/maxp
use core::num::NonZeroU16;
use crate::parser::Stream;
// We care only about `numGlyphs`.
pub fn parse(data: &[u8]) -> Option<NonZeroU16... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/ttf-parser-0.10.1/src/tables/maxp.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let num_glyphs = super::parse(&[
0x00, 0x01, 0x00, 0x00, // version: 1
0x00, 0x01, // number of glyphs: 1
0x00, 0x00, // maximum points in a non-composite glyph: 0
0x00, 0x00, // maximum contours in a non-composite glyph: 0
0x00, 0x00, //... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/ttf-parser-0.10.1/src/tables/maxp.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Err(error.to_string_lossy().into_owned());
}
for shader in shaders {
unsafe {
gl.DetachShader(program_id, shader.id());
}
}
Ok(Program {
id: program_id,
gl: gl.clone(),
})
}
... | code_fim | hard | {
"lang": "rust",
"repo": "DayBr3ak/learn_opengl",
"path": "/src/support/render_gl.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DayBr3ak/learn_opengl path: /src/support/render_gl.rs
use super::resources::{Error as ResourcesError, Resources};
use super::Gl;
use gl::Gles;
use std;
use std::ffi::CString;
#[derive(Debug)]
pub enum Error {
ResourceLoad { name: String, inner: ResourcesError },
CanNotDetermineShaderTy... | code_fim | hard | {
"lang": "rust",
"repo": "DayBr3ak/learn_opengl",
"path": "/src/support/render_gl.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Drop for Shader {
fn drop(&mut self) {
unsafe {
self.gl.DeleteShader(self.id);
}
}
}
pub struct Program {
id: gl::types::GLuint,
gl: Gles,
}
impl Program {
pub fn id(&self) -> gl::types::GLuint {
self.id
}
fn from_shaders(gl: &Gl, shade... | code_fim | hard | {
"lang": "rust",
"repo": "DayBr3ak/learn_opengl",
"path": "/src/support/render_gl.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> |y|
(x, y)
)
)
}};
($e:expr) => {{
$e
}};
() => { iter::empty() };
}<|fim_prefix|>// repo: sirkibsirkib/stave_cardgame path: /rust/src/macros.rs
macro_rules! lex_iter {
($e:expr, $f:expr, $g:expr) => {{
$e.flat_map(
move |x|
$f.flat_map(
move |y|
$g.map(
move |z|
... | code_fim | medium | {
"lang": "rust",
"repo": "sirkibsirkib/stave_cardgame",
"path": "/rust/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sirkibsirkib/stave_cardgame path: /rust/src/macros.rs
macro_rules! lex_iter {
($e:expr, $f:expr, $g:expr) => {{
$e.flat_map(
move <|fim_suffix|> |y|
(x, y)
)
)
}};
($e:expr) => {{
$e
}};
() => { iter::empty() };
}<|fim_middle|>|x|
$f.flat_map(
move |y|
$g.map(
... | code_fim | medium | {
"lang": "rust",
"repo": "sirkibsirkib/stave_cardgame",
"path": "/rust/src/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kjunichi/imgtypers path: /src/lib.rs
extern crate libc;
pub mod ffi;
pub fn term_wait() -> () {
unsafe {
ffi::termWait();
}
}
pub fn term_init() -> () {
unsafe {
ffi::termInit();
}
}
pub fn term_flush() -> () {
unsafe {
ffi::termFlush();
}
}
pu... | code_fim | hard | {
"lang": "rust",
"repo": "kjunichi/imgtypers",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(not(target_os="windows"))]
static mut G_FCNTL_NONBLOCK: bool = false;
#[cfg(not(target_os="windows"))]
pub fn term_get_esc_key() -> bool {
unsafe {
if !G_FCNTL_NONBLOCK {
libc::fcntl(0, libc::F_SETFL, libc::O_NONBLOCK);
G_FCNTL_NONBLOCK = true;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "kjunichi/imgtypers",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn day21_test() {
const EXAMPLE: &str = "#ip 1
seti 123 0 2
bani 2 456 2
eqri 2 72 2
addr 2 1 1
seti 0 0 1
seti 0 3 2
bori 2 65536 5
seti 4843319 1 2
bani 5 255 4
addr 2 4 2
bani 2 16777215 2
muli 2 65899 2
bani 2 16777215 2
gtir 256 5 4
addr 4 1 1
addi 1 1 1
seti 27 4 1
seti 0 7 4
addi 4 1 3
... | code_fim | hard | {
"lang": "rust",
"repo": "all-in-one-of/advent_of_code_2018",
"path": "/src/day21.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: all-in-one-of/advent_of_code_2018 path: /src/day21.rs
day!(
day21,
"https://adventofcode.com/2018/day/21/input",
part1,
part2
);
use crate::day19::{Instruction, Opcode, Program, ProgramState, Register};
use std::collections::HashSet;
fn parse_input(input: &str) -> Result<(Progr... | code_fim | hard | {
"lang": "rust",
"repo": "all-in-one-of/advent_of_code_2018",
"path": "/src/day21.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnnyeric/glot-run2 path: /src/glot_run/api/images/list.rs
use crate::glot_run::config;
use crate::glot_run::api;
use crate::glot_run::language;
use crate::glot_run::datastore;
use crate::glot_run::file;
#[derive(Debug, Eq, PartialEq, serde::Serialize)]
pub struct Image {
name: String,
... | code_fim | medium | {
"lang": "rust",
"repo": "johnnyeric/glot-run2",
"path": "/src/glot_run/api/images/list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn to_image(language: &language::Language) -> Image {
Image{
name: language.name.clone(),
url: format!("https://hub.docker.com/r/glot/{}/", language.name),
}
}
fn handle_datastore_error(err: file::ReadJsonError) -> api::ErrorResponse{
api::ErrorResponse{
status_code: ... | code_fim | hard | {
"lang": "rust",
"repo": "johnnyeric/glot-run2",
"path": "/src/glot_run/api/images/list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simnalamburt/obj-rs path: /obj-rs/tests/issue-50.rs
use obj::{load_obj, Obj};
use std::io::Cursor;
#[test]
fn issue_50() {
let test_cases: [&[u8]; 4] = [
b"s 1000000000000000000",
b"s 100000000000000000",
b"s 100000000000",
b"s 67108864",
];
<|fim_suffix... | code_fim | medium | {
"lang": "rust",
"repo": "simnalamburt/obj-rs",
"path": "/obj-rs/tests/issue-50.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Expect empty Obj
assert_eq!(obj.name, None);
assert_eq!(obj.vertices, vec![]);
assert_eq!(obj.indices, vec![]);
}
}<|fim_prefix|>// repo: simnalamburt/obj-rs path: /obj-rs/tests/issue-50.rs
use obj::{load_obj, Obj};
use std::io::Cursor;
#[test]
fn issue_50() {
... | code_fim | medium | {
"lang": "rust",
"repo": "simnalamburt/obj-rs",
"path": "/obj-rs/tests/issue-50.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for data in test_cases {
let obj: Obj = load_obj(Cursor::new(data)).expect("Expect success");
// Expect empty Obj
assert_eq!(obj.name, None);
assert_eq!(obj.vertices, vec![]);
assert_eq!(obj.indices, vec![]);
}
}<|fim_prefix|>// repo: simnalamburt/obj-rs p... | code_fim | medium | {
"lang": "rust",
"repo": "simnalamburt/obj-rs",
"path": "/obj-rs/tests/issue-50.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thibault-martinez/bee-p path: /bee-bundle/src/bundle.rs
use crate::transaction::Transaction;
/// A newtype to represent a number of transactions, that hides the internal data layout.
pub struct Transactions(Vec<Transaction>);
/// `Bundle`s are messages on the network of one or more `Transactio... | code_fim | medium | {
"lang": "rust",
"repo": "thibault-martinez/bee-p",
"path": "/bee-bundle/src/bundle.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Bundle {
pub fn transactions(&self) -> &Transactions {
&self.transactions
}
}<|fim_prefix|>// repo: thibault-martinez/bee-p path: /bee-bundle/src/bundle.rs
use crate::transaction::Transaction;
/// A newtype to represent a number of transactions, that hides the internal data layout.
... | code_fim | medium | {
"lang": "rust",
"repo": "thibault-martinez/bee-p",
"path": "/bee-bundle/src/bundle.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Disasm/rust-litex-pac path: /src/uart/rxfull.rs
#[doc = "Reader of register RXFULL"]
pub type R = crate::R<u32, super::RXFU<|fim_suffix|>(&self) -> RXFULL_R {
RXFULL_R::new((self.bits & 0x01) != 0)
}
}<|fim_middle|>LL>;
#[doc = "Reader of field `rxfull`"]
pub type RXFULL_R = crate::R... | code_fim | medium | {
"lang": "rust",
"repo": "Disasm/rust-litex-pac",
"path": "/src/uart/rxfull.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>(&self) -> RXFULL_R {
RXFULL_R::new((self.bits & 0x01) != 0)
}
}<|fim_prefix|>// repo: Disasm/rust-litex-pac path: /src/uart/rxfull.rs
#[doc = "Reader of register RXFULL"]
pub type R = crate::R<u32, super::RXFULL>;
#[doc = "Reader of field `rxfull`"]
pub type RXFULL_R = crate::R<bool, <|fim_m... | code_fim | medium | {
"lang": "rust",
"repo": "Disasm/rust-litex-pac",
"path": "/src/uart/rxfull.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaxOhn/Bathbot path: /bathbot-macros/src/util.rs
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote, ToTokens};
use syn::{
parenthesized,
parse::{Parse, ParseStream},
punctuated::Punctuated,
token::Comma,
Ident, Lit, Result, Token,
};
pub struct Pa... | code_fim | hard | {
"lang": "rust",
"repo": "MaxOhn/Bathbot",
"path": "/bathbot-macros/src/util.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl IdentExt for Ident {
fn to_uppercase(&self) -> Self {
format_ident!("{}", self.to_string().to_uppercase(), span = self.span())
}
}
pub struct AsOption<T>(pub Option<T>);
impl<T: ToTokens> ToTokens for AsOption<T> {
fn to_tokens(&self, stream: &mut TokenStream2) {
matc... | code_fim | hard | {
"lang": "rust",
"repo": "MaxOhn/Bathbot",
"path": "/bathbot-macros/src/util.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rednim/blpapi-rs path: /blpapi/src/lib.rs
pub mod correlation_id;
pub mod datetime;
pub mod element;
pub mod errors;
pub mod event;
pub<|fim_suffix|>api_derive::*;
pub use errors::Error;
pub use ref_data::RefData;
pub use session::SessionSync;<|fim_middle|> mod message;
pub mod message_iterator;... | code_fim | medium | {
"lang": "rust",
"repo": "rednim/blpapi-rs",
"path": "/blpapi/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>od service;
pub mod session;
pub mod session_options;
#[cfg(feature = "derive")]
pub use blpapi_derive::*;
pub use errors::Error;
pub use ref_data::RefData;
pub use session::SessionSync;<|fim_prefix|>// repo: rednim/blpapi-rs path: /blpapi/src/lib.rs
pub mod correlation_id;
pub mod datetime;
pub mod ele... | code_fim | medium | {
"lang": "rust",
"repo": "rednim/blpapi-rs",
"path": "/blpapi/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/assembly/x86_64-no-jump-tables.rs
// Test that jump tables are (not) emitted when the `-Zno-jump-tables`
// flag is (not) set.
// revisions: unset set
// assembly-output: emit-asm
// compile-flags: -O
// [set] compile-flags: -Zno-jump-tables
// only-x86_64
// ignore-... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/assembly/x86_64-no-jump-tables.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
// CHECK-LABEL: foo:
#[no_mangle]
pub unsafe fn foo(x: i32) {
// unset: LJTI0_0
// set-NOT: LJTI0_0
match x {
1 => bar1(),
2 => bar2(),
3 => bar3(),
4 => bar4(),
5 => bar5(),
_ => bar6(),
}
}<|fim_prefix|>// repo: rust-lang/rust path: /te... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/assembly/x86_64-no-jump-tables.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sammosampson/rust-opengl path: /src/render_gl/texture.rs
use crate::render_gl::buffer::TextureBuffer;
use crate::render_gl::shader::Program;
use crate::resources::{Resources, Error};
pub struct Texture<T> where T : TextureLayoutType {
gl: gl::Gl,
texture_id: gl::types::GLuint,
textu... | code_fim | hard | {
"lang": "rust",
"repo": "sammosampson/rust-opengl",
"path": "/src/render_gl/texture.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn send_to_shader_property(&self, program: &Program, property_name: &str) {
self.texture.activate();
self.texture.bind();
self.texture.set_texture(&self.data, self.dimensions);
self.texture.set_linear_texture_filter();
program.set_used();
program.se... | code_fim | hard | {
"lang": "rust",
"repo": "sammosampson/rust-opengl",
"path": "/src/render_gl/texture.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> conn.connect(&app_config.db_creds);
migrate(&conn.get_connection());
debug!("Organizing...");
println!("[+] Organizing...");
use crate::schema::configs::dsl::*;
let last_stop = configs
.filter(key.eq("last_processed_dump_id"))
.select(value)
.get_result::<Op... | code_fim | hard | {
"lang": "rust",
"repo": "Y0h4n3s/tools",
"path": "/rust/dubppi/organizer/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Y0h4n3s/tools path: /rust/dubppi/organizer/src/lib.rs
#![allow(unused)]
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate diesel_migrations;
#[macro_use]
extern crate log;
extern crate pretty_env_logger;
use std::process::exit;
use std::thread;
use diesel::*;
use diesel::{ConnectionE... | code_fim | hard | {
"lang": "rust",
"repo": "Y0h4n3s/tools",
"path": "/rust/dubppi/organizer/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl<'a> flatbuffers::Follow<'a> for DeleteOperations<'a> {
type Inner = DeleteOperations<'a>;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
_tab: flatbu... | code_fim | hard | {
"lang": "rust",
"repo": "sunng87/influxdb_iox",
"path": "/entry/src/entry_generated.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl flatbuffers::Verifiable for BytesValues<'_> {
#[inline]
fn run_verifier(
v: &mut flatbuffers::Verifier,
pos: usize,
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
... | code_fim | hard | {
"lang": "rust",
"repo": "sunng87/influxdb_iox",
"path": "/entry/src/entry_generated.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sunng87/influxdb_iox path: /entry/src/entry_generated.rs
}
pub enum TableWriteBatchOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct TableWriteBatch<'a> {
pub _tab: flatbuffers::Table<'a>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "sunng87/influxdb_iox",
"path": "/entry/src/entry_generated.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ducktail/aoj path: /vol06/rust/q0658.rs
fn main(){
let hw: Vec<usize> = read_vec();
let h = hw[0];
let w = hw[1];
let vvc: Vec<Vec<char>> = (0 .. h).map(|_| {let s: String = read(); s.chars().collect()}).collect();
let mut vo: Vec<Vec<usize>> = vec![vec![0; w]; h];
let... | code_fim | medium | {
"lang": "rust",
"repo": "ducktail/aoj",
"path": "/vol06/rust/q0658.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn set_prop_val<T: 'static>(&mut self, name: &str, value: T);
}
impl<P> PropertiesVal for P
where
P: Properties,
{
#[inline]
fn prop_val<T: 'static>(&self, name: &str) -> Option<&T> {
self.prop(name).and_then(|p| p.any().downcast_ref::<T>())
}
#[inline]
fn set_prop_va... | code_fim | hard | {
"lang": "rust",
"repo": "alec-deason/bevy",
"path": "/crates/bevy_property/src/properties.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alec-deason/bevy path: /crates/bevy_property/src/properties.rs
use crate::{DynamicProperties, Property, PropertyType, PropertyVal};
pub trait Properties: Property {
fn prop(&self, name: &str) -> Option<&dyn Property>;
fn prop_mut(&mut self, name: &str) -> Option<&mut dyn Property>;
... | code_fim | hard | {
"lang": "rust",
"repo": "alec-deason/bevy",
"path": "/crates/bevy_property/src/properties.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rene-Ulmer/Tropical-Frency path: /src/entity.rs
use camera;
use collision;
use level;
use projectile;
use {Canvas, InputState};
<|fim_suffix|> /// Got hit by a projectile.
fn on_hit(&mut self, projectile: &projectile::Projectile, level: &level::Level);
}<|fim_middle|>// All entities can ... | code_fim | hard | {
"lang": "rust",
"repo": "Rene-Ulmer/Tropical-Frency",
"path": "/src/entity.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Got hit by a projectile.
fn on_hit(&mut self, projectile: &projectile::Projectile, level: &level::Level);
}<|fim_prefix|>// repo: Rene-Ulmer/Tropical-Frency path: /src/entity.rs
use camera;
use collision;
use level;
use projectile;
use {Canvas, InputState};
<|fim_middle|>// All entities can ... | code_fim | hard | {
"lang": "rust",
"repo": "Rene-Ulmer/Tropical-Frency",
"path": "/src/entity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Draw the object to the canvas.
fn draw(&self, canvas: &mut Canvas, camera: &camera::Camera);
/// Got hit by a projectile.
fn on_hit(&mut self, projectile: &projectile::Projectile, level: &level::Level);
}<|fim_prefix|>// repo: Rene-Ulmer/Tropical-Frency path: /src/entity.rs
use camera... | code_fim | hard | {
"lang": "rust",
"repo": "Rene-Ulmer/Tropical-Frency",
"path": "/src/entity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cksac/graphql-rs path: /graphql/src/types.rs
fCell<HashMap<String, GraphQLField>>,
interfaces: Option<HashMap<String, Rc<GraphQLInterface>>>,
}
impl GraphQLObject {
pub fn replace_field_placeholder_type<T: GraphQLOutput + 'static>(&self,
... | code_fim | hard | {
"lang": "rust",
"repo": "cksac/graphql-rs",
"path": "/graphql/src/types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cksac/graphql-rs path: /graphql/src/types.rs
put for T {}
blanket_impl! { GraphQLInput for GraphQLEnum, GraphQLInputObject, GraphQLInputList, GraphQLInputOptional }
pub trait GraphQLOutput: GraphQLType {}
impl<T: GraphQLScalar> GraphQLOutput for T {}
blanket_impl! { GraphQLOutput for GraphQLObj... | code_fim | hard | {
"lang": "rust",
"repo": "cksac/graphql-rs",
"path": "/graphql/src/types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl GraphQLArgumentBuilder {
fn new(name: &str) -> GraphQLArgumentBuilder {
GraphQLArgumentBuilder {
name: name.to_owned(),
description: None,
default_value: None,
typ: None,
}
}
pub fn type_of<T: GraphQLInput + 'static>(mut self, typ: &Rc<T>) -> GraphQLArgumentBuil... | code_fim | hard | {
"lang": "rust",
"repo": "cksac/graphql-rs",
"path": "/graphql/src/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.