blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
e3d2b7264f3b666133a874c09aaf4bd33459afac | Rust | nickbp/tokio-scgi | /src/client.rs | UTF-8 | 4,278 | 2.984375 | 3 | [
"MIT"
] | permissive | #![deny(warnings)]
use bytes::{BufMut, BytesMut};
use std::io;
use tokio_util::codec::{Decoder, Encoder};
const NUL: u8 = b'\0';
/// A parsed SCGI request header with key/value header data, and/or bytes from the raw request body.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum SCGIRequest {
/// The Vec contains ... | true |
5e063d8a288120ea367ddd4c7679dfc05f0aeb94 | Rust | TakaakiFuruse/cargo-expand | /src/main.rs | UTF-8 | 11,164 | 2.546875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | mod cmd;
mod config;
mod edit;
mod error;
mod fmt;
mod opts;
use std::env;
use std::ffi::OsString;
use std::fs;
use std::io::{self, BufRead, Write};
use std::path::{Path, PathBuf};
use std::process::{self, Command, Stdio};
use atty::Stream::{Stderr, Stdout};
use prettyprint::{PagingMode, PrettyPrinter};
use quote::qu... | true |
a9392347e1009496c021d53e8040aada3702cef5 | Rust | bestrauc/Advent-of-Code-2018 | /src/solutions/advent2.rs | UTF-8 | 2,983 | 3.390625 | 3 | [] | no_license | use std::collections::HashMap;
use std::collections::HashSet;
use solutions::utils;
static INPUT: &str = "data/input2";
// Problem 1
// ==================================================
// we operate over chars, not unicode code points, but
// it doesn't matter since we mostly have ascii here
fn count_frequencies(... | true |
d7513759a3994e580123f9a133e86370b1fcc690 | Rust | glemercier/grin | /util/src/types.rs | UTF-8 | 4,446 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... | true |
d9b8cc29e8664a96bf51de3ee7c9a07bee836776 | Rust | yeethawe/PokemonRust | /pokemon_rust/src/config.rs | UTF-8 | 1,205 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | //! Types related to the main configuration file (`settings.ron`).
use serde::{Deserialize, Serialize};
/// Describes the available fields of `settings.ron`.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct GameConfig {
/// The speed of the player when they're walking, in pixels/second.
pub... | true |
b15a429f878a0e98434b810d932a29fd79da314c | Rust | palacaze/euler-rs | /src/bin/euler-027.rs | UTF-8 | 1,566 | 3.59375 | 4 | [] | no_license | // Quadratic primes
//
// Euler discovered the remarkable quadratic formula:
//
// n² + n + 41
//
// It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39.
// However, when n = 40, 402 + 40 + 41 = 40(40 + 1) + 41 is divisible by 41, and certainly when n = 41, 41² + 41 + 41 is clear... | true |
731513a25cd6ad08aa2c257b5df60e753cd35732 | Rust | rchaser53/rust_playground | /src/future_cpupool.rs | UTF-8 | 717 | 2.671875 | 3 | [] | no_license | use futures_cpupool::{CpuFuture, CpuPool};
fn fuga (thread_pool: &CpuPool, num: i16) -> CpuFuture<(), ()> {
thread_pool.spawn_fn(move || {
thread::sleep(Duration::from_millis((num * 300) as u64));
println!("{}", num);
Ok(())
})
}
fn main() {
let start = SteadyTime::now();
let thread_pool = CpuPool... | true |
ca3db29b68883f7c695a39ff89cf3409f658119a | Rust | Lucky3028/minecraft_decorated_strings | /src/format_code.rs | UTF-8 | 1,569 | 3.359375 | 3 | [
"MIT"
] | permissive | use std::fmt::Debug;
use strum::{EnumProperty, IntoEnumIterator};
#[derive(EnumProperty, EnumIter, Debug)]
pub enum FmtCode {
#[strum(props(code = "§l", name_ja = "太字"))]
Bold,
#[strum(props(code = "§o", name_ja = "斜め"))]
Italic,
#[strum(props(code = "§n", name_ja = "下線"))]
Underline,
#[str... | true |
a3d582e3fe7f8398de42e219150f620ef71d118f | Rust | mintframework/wasm-gzip | /src/lib.rs | UTF-8 | 1,768 | 2.78125 | 3 | [] | no_license | use js_sys::JSON;
use libflate::gzip::{Decoder, Encoder};
use std::io::{self, Read};
use wasm_bindgen::prelude::*;
/// Compresses binary data using GZip.
#[wasm_bindgen(js_name = "compressGzip")]
pub fn gzip_compress(mut data: &[u8]) -> Option<Vec<u8>> {
let mut encoder: Encoder<Vec<u8>> = Encoder::new(Vec::new()).un... | true |
d38fa9bfe4582358aabb82f586c4f8239aa6e0ba | Rust | yingliufengpeng/rust_language | /ch04_effective_rust/src/section10_borrow_and_as_ref.rs | UTF-8 | 1,244 | 3.953125 | 4 | [] | no_license |
//!
//! The Borrow trait is used when you're writing a data structure, and you want to use either an owned
//! or borrowed type as synonymous for some purpose.
//!
//! The AsRef trait is a conversion trait. It's used for converting some value to a reference in generic
//! code
//!
//! Choose Borrow when you want to ab... | true |
98f90b486587b22f372de0824ca81700b8601d29 | Rust | GaloisInc/mir-verifier | /lib/stdarch/crates/core_arch/src/x86_64/sse41.rs | UTF-8 | 1,915 | 2.90625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive"
] | permissive | //! `i686`'s Streaming SIMD Extensions 4.1 (SSE4.1)
use crate::{
core_arch::{simd_llvm::*, x86::*},
mem::transmute,
};
#[cfg(test)]
use stdarch_test::assert_instr;
/// Extracts an 64-bit integer from `a` selected with `imm8`
///
/// [Intel's documentation](https://software.intel.com/sites/landingpage/Intrins... | true |
9f4d15efdd2fdc0699dbcc7149a60e565e0c3d22 | Rust | sunhuachuang/study-demo | /rust/rust_primer/rc_arc.rs | UTF-8 | 1,270 | 3.453125 | 3 | [] | no_license | use std::rc::Rc;
use std::sync::Arc;
use std::thread;
/// Rc 单线程
/// Arc 多线程
/// 多个对象使用同一个对象
struct Owner {
name: String,
}
struct Gradget {
id: i32,
owner: Rc<Owner>,
}
fn main() {
let five = Rc::new(5);
let five2 = five.clone();
let five3 = five.clone();
println!("{}, {}, {}", five, fi... | true |
bd17f061c80b16690b8a1acb691a5787eed14518 | Rust | alexcrichton/cargo-sysroot | /src/main.rs | UTF-8 | 8,858 | 2.59375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #![deny(warnings)]
extern crate clap;
extern crate fern;
extern crate rustc_version;
extern crate tempdir;
#[macro_use]
extern crate log;
use std::fs::{self, File};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use clap::{App, AppSettings, Arg, SubCommand};
// TODO... | true |
ed70c8371b9f9c89f85eddfb7f15a1fe72ed98cf | Rust | pmeredit/shelltool | /src/main.rs | UTF-8 | 4,808 | 2.9375 | 3 | [] | no_license | use clap::{App, Arg, SubCommand};
use regex::Regex;
use std::{
fmt::Debug,
fs::{copy, hard_link, rename},
os::unix::fs::symlink,
path::{Path, PathBuf},
str::FromStr,
};
#[derive(Debug)]
enum Error {
Io(std::io::Error),
Regex(regex::Error),
Convert(std::convert::Infallible),
CustomEr... | true |
d1fbc66c8319cf09ab9bc8aa816ae0238381db20 | Rust | etherswap/ethereyum | /src/client/streaming/transaction.rs | UTF-8 | 4,360 | 2.609375 | 3 | [
"MIT"
] | permissive | use std::cmp;
use std::collections::{BTreeSet, VecDeque};
use std::mem;
use std::ops::Range;
use std::sync::Arc;
use std::time::{Duration, Instant};
use ethereum_models::objects::Transaction;
use ethereum_models::types::H256;
use futures::{Async, Future, Stream};
use serde::de::DeserializeOwned;
use serde_json::Value;... | true |
5572731a0dc882b3e49fac838ed9372f9b7ce362 | Rust | Bill13579/discord-snake | /src/lib.rs | UTF-8 | 7,943 | 2.875 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, HashSet};
use rand::{thread_rng, Rng, rngs::ThreadRng, distributions::Uniform};
const PLAYERS: [&str; 10] = ["#", "@", "%", "$", "z", "*", "+", "=", "?", "Q"];
const BOARD_SIZE: Vector2 = Vector2(64, 24);
pub const UP: Vector2 = Vector2(0, -1);
pub const RIGHT: Vector2 = Vector2(1, 0)... | true |
d8d6bde1d8d81734238cf17c1d8ff4c1fbdace64 | Rust | sveolon/advent_of_code_2019 | /12/12_1.rs | UTF-8 | 1,887 | 3 | 3 | [] | no_license | /*
<x=-3, y=10, z=-1>
<x=-12, y=-10, z=-5>
<x=-9, y=0, z=10>
<x=7, y=-5, z=-3>*/
fn print_matrix(name: &str, matrix: &[[i32; 3]; 4]) {
println!("{}", name);
for l in 0..4 {
for i in 0..3 {
print!("{},", matrix[l][i]);
}
print!("\n");
}
print!("\n");
}
fn main() {
... | true |
85e5b575d036575dc3e3f2d09707c2d634217a0a | Rust | adamhammes/pokemon_go_data | /src/evaluation/mod.rs | UTF-8 | 2,762 | 4.1875 | 4 | [
"MIT"
] | permissive | use std::cmp::Eq;
mod cp_multiplier;
#[derive(Debug)]
/// Represents a Pokemon's level.
pub struct Level {
val: f64,
}
const MIN_LEVEL: f64 = 1.;
const MAX_LEVEL: f64 = 39.;
impl Level {
/// Create a new `Level` from the given parameter. Returns `None` if the given value is not a valid
/// level.
//... | true |
ec78c2278aab4eb3728db6deecef68bff5d29841 | Rust | suguru03/leetcode | /algorithms/0784.Letter Case Permutation/solution.rs | UTF-8 | 1,052 | 3.484375 | 3 | [] | no_license | pub struct Solution;
impl Solution {
pub fn letter_case_permutation(s: String) -> Vec<String> {
if s.len() == 0 {
return vec![String::from("")];
}
let mut chars: Vec<_> = s.chars().collect();
let last = chars.pop().unwrap();
Solution::letter_case_permutation(char... | true |
55d8c571466e46dc8167cc156b0118063850c786 | Rust | alexxuyang/tokio-examples | /examples/fold.rs | UTF-8 | 1,240 | 3.28125 | 3 | [] | no_license | extern crate futures;
use futures::{stream, Future, Stream};
use std::io;
use futures::future::ok;
fn get_data() -> impl Future<Item = u32, Error = io::Error> {
ok(10)
}
fn get_ok_data() -> impl Future<Item = Vec<u32>, Error = io::Error> {
let mut dst = vec![];
// Start with an unbounded stream that use... | true |
7ccab7453afaeb711ebc4772497d018eaf8beaac | Rust | sourgrasses/pinguin | /src/packet.rs | UTF-8 | 4,049 | 2.984375 | 3 | [
"MIT"
] | permissive | use byteorder::{BigEndian, ByteOrder};
use pnet::packet::icmp::IcmpPacket;
//use pnet::packet::util::checksum;
use pnet_macros_support::packet::Packet;
use std::convert::From;
use std::fmt;
use std::io::Write;
use std::ptr;
#[derive(Clone)]
pub(crate) struct TunnelPacket {
pub(crate) id: u16,
pub(crate) seq:... | true |
f4cff430eda9e7903968ff7808ccc5101192c70b | Rust | TheNeikos/rpg | /shared/src/gameloop.rs | UTF-8 | 626 | 3.0625 | 3 | [] | no_license | use std::thread;
use clock_ticks::precise_time_ns;
pub enum LoopAction {
Quit,
Continue
}
pub fn game_loop<F>(tick: u64, mut f: F) where F: FnMut(u64) -> LoopAction {
let mut acc = 0;
let mut previous_clock = precise_time_ns();
loop {
let now = precise_time_ns();
match f(now - pr... | true |
8c6b8e250182fb26f168837d7e5bb1c75b8fcf79 | Rust | Happy-Ferret/lark | /components/mir/src/lib.rs | UTF-8 | 4,741 | 3.234375 | 3 | [] | no_license | pub type DefId = usize;
pub type VarId = usize;
// Dummy for now
#[derive(Copy, Clone, Debug)]
pub struct Ty {
def_id: DefId,
}
#[derive(Debug)]
pub struct SourceInfo;
//Lark MIR representation of a single function
#[derive(Debug)]
pub struct Function {
pub basic_blocks: Vec<BasicBlock>,
//First local =... | true |
d2c5d860d0d3f8818c0044243f2ca8081da4b5c1 | Rust | scyptnex/computing | /rtest/src/bin/guess.rs | UTF-8 | 638 | 3.5 | 4 | [] | no_license | extern crate rand;
use std::io;
use rand::Rng;
fn main() {
let ans = rand::thread_rng().gen_range(1,101);
println!("Guess the number!");
loop{
println!("");
println!("Please input your guess.");
let mut guess = String::new();
io::stdin().read_line(&mut guess)
.o... | true |
eab25d956d8167b4fe3c3bfe1d4f979349316a03 | Rust | Ventmere/newegg | /newegg/src/types.rs | UTF-8 | 1,154 | 2.859375 | 3 | [] | no_license | use serde_derive::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct NeweggApiResponse<B> {
is_success: IsSuccess,
pub operation_type: String,
#[serde(rename = "sellerID")]
pub seller_id: Option<String>,
pub response_body: B,
pub memo: Option<S... | true |
e52efcd885fad24b8fb657e09f8d444b5a9561cc | Rust | albmar/comdirect_api | /src/serde/order_type.rs | UTF-8 | 2,278 | 2.703125 | 3 | [] | no_license | use pecunia::{serde_option, serde_with};
use serde::{Deserialize, Serialize};
use wall_street::order::OrderType;
#[derive(Serialize, Deserialize)]
#[serde(remote = "OrderType")]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
enum OrderTypeDef {
Market,
Limit,
StopMarket,
StopLimit,
TrailingStopMarke... | true |
24566bd278c7fda9d7f74612a6e59cf9cf210f89 | Rust | cbzehner/launchpad | /services/api/src/configs/kratos_client.rs | UTF-8 | 679 | 2.875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::env;
use url::Url;
pub(crate) struct KratosClient(Url);
impl KratosClient {
pub(crate) fn new(url: impl Into<Option<Url>>) -> Self {
match url.into() {
Some(url) => Self(url),
None => match env::var("KRATOS_URL") {
Ok(url) => Self(Url::parse(&url).expect("I... | true |
d0beba8d1818e952e6cc8ed66b9ef83a69a19b97 | Rust | Aidiakapi/advent-of-code-2016 | /src/day09.rs | UTF-8 | 2,973 | 3.296875 | 3 | [
"Unlicense"
] | permissive | use crate::prelude::*;
fn decompress(s: &str) -> Result<String> {
use parsers::*;
#[derive(Debug, Clone)]
enum Section<'s> {
Text(&'s str),
Repetition(usize, &'s str),
}
let section = alt((
map(alpha1, |s: &str| Section::Text(s)),
map(
flat_map(
... | true |
82c06521441a8e137bee7e12f6780c19d5162a64 | Rust | hoodielive/rust | /2021/study-rust/src/namespaces.rs | UTF-8 | 243 | 3.21875 | 3 | [] | no_license | use std::collections::LinkedList;
fn main() {
// linked list is a struct
let mut ll = LinkedList::new();
ll.push_back(1);
ll.push_back(2);
ll.push_back(4);
for item in ll {
println!("{}", foo);
}
}
| true |
bcdb73262deb235f11157b79ec594bf4c7db3eca | Rust | udoprog/fixed-map | /src/map/storage/singleton.rs | UTF-8 | 3,257 | 3.359375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use core::mem;
use crate::map::{Entry, MapStorage};
use crate::option_bucket::{NoneBucket, OptionBucket, SomeBucket};
/// [`MapStorage`] type that can only inhabit a single value (like `()`).
#[repr(transparent)]
#[derive(Clone, Copy)]
pub struct SingletonMapStorage<V> {
inner: Option<V>,
}
impl<V> PartialEq for... | true |
b43a4e3a4e884533f2e67f45fe704c5f616baaf6 | Rust | ChunMinChang/cubeb-rs | /cubeb-api/src/sample.rs | UTF-8 | 620 | 2.546875 | 3 | [
"ISC",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright © 2017-2018 Mozilla Foundation
//
// This program is made available under an ISC-style license. See the
// accompanying file LICENSE for details.
/// An extension trait which allows the implementation of converting
/// void* buffers from libcubeb-sys into rust slices of the appropriate
/// type.
pub trai... | true |
3fb8a4d87487302dd4ce8211b03fedee47f1aecf | Rust | melotic/docx-rs | /src/formatting/numbering_property.rs | UTF-8 | 1,153 | 2.875 | 3 | [
"MIT"
] | permissive | use strong_xml::{XmlRead, XmlWrite};
use crate::__xml_test_suites;
use crate::formatting::{IndentLevel, NumberingId};
/// Numbering Property
///
/// ```rust
/// use docx::formatting::*;
///
/// let prop = NumberingProperty::from((20, 40));
/// ```
#[derive(Debug, Default, XmlRead, XmlWrite)]
#[cfg_attr(test, derive(P... | true |
5182e8ae378cf59f298a9468584b139d26006118 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/fuka5/src/bin/a.rs | UTF-8 | 445 | 2.671875 | 3 | [] | no_license | use proconio::input;
fn main() {
loop {
input! {
n: usize,
k: usize,
};
if n == 0 && k == 0 {
break;
}
input! {
mut x: [usize; n],
}
x.sort();
let mut sum = 0_usize;
let mut count = 0_usize;
... | true |
8616d6d5f2834ffb3ff631e0f15f0538206c1e0b | Rust | vadixidav/ndimage | /benches/image_access.rs | UTF-8 | 3,536 | 2.734375 | 3 | [
"MIT"
] | permissive | #![feature(test)]
extern crate image;
extern crate ndimage;
extern crate test;
use test::Bencher;
const W: u32 = 1920;
const H: u32 = 1080;
#[cfg(test)]
mod bench_ndimage {
use super::*;
use ndimage::core::{Image2D, Image2DMut, ImageBuffer2D, Luma, Rect};
#[bench]
fn fill_gray(b: &mut Bencher) {
... | true |
83b26044eb56c23fd0c4410da80a3ae2327830ca | Rust | sueken5/resea | /libs/resea/print.rs | UTF-8 | 3,567 | 2.671875 | 3 | [
"MIT",
"CC0-1.0"
] | permissive | use crate::channel::Channel;
use crate::idl;
use core::fmt::Write;
pub struct Printer();
impl Printer {
pub const fn new() -> Printer {
Printer()
}
}
impl Write for Printer {
fn write_char(&mut self, c: char) -> core::fmt::Result {
printchar(c as u8);
Ok(())
}
fn write_st... | true |
b8b2bffce17e1f101682d6b2492e0c76b7c08d42 | Rust | jjsloboda/aoc2019 | /nbodies/src/main.rs | UTF-8 | 2,213 | 2.921875 | 3 | [] | no_license | use std::io;
use std::fs::File;
use std::io::{BufReader, BufRead};
use num::integer::lcm;
use regex::Regex;
use nbodies::{Body, System};
fn main() -> io::Result<()> {
let point_regex = Regex::new(
r"^<x=(-?[0-9]+), y=(-?[0-9]+), z=(-?[0-9]+)>$").unwrap();
let file = File::open("input.txt")?;
let... | true |
37dbc3d77f77676240c54719a83918aa51ac7262 | Rust | xNul/einrain-rs | /einrain_commands/src/classes.rs | UTF-8 | 3,561 | 2.703125 | 3 | [
"MIT"
] | permissive | use std::{cmp::Ordering, include_str};
use serde::{Deserialize, Serialize};
use lazy_static::lazy_static;
#[derive(Debug, poise::SlashChoiceParameter)]
pub enum ClassChoice {
#[name = "Aegis Fighter"]
AegisFighter,
#[name = "Blast Archer"]
BlastArcher,
#[name = "Spell Caster"]
SpellCaster,
... | true |
24da267006c2d2eb7369f4415bf9dbb4762f2730 | Rust | arosspope/learn-rust | /types-traits-lifetimes/aggregator/src/lib.rs | UTF-8 | 1,278 | 3.15625 | 3 | [
"MIT"
] | permissive | //Traits allow us to abstract over behavior that types can have in common
//Traits are often called 'interfaces' in other languages (with some differences)
//The behavior of a type consists of the methods we can call on that type. Different types share the same behavior if we can call the same methods on all of those ... | true |
33a09c36e497eb2f25cd07dfccdc46a3b7a5f68f | Rust | claucece/openmls | /src/extensions/test_extensions.rs | UTF-8 | 1,728 | 3.078125 | 3 | [
"MIT"
] | permissive | //! # Extensions Unit tests
//! Some basic unit tests for extensions
//! Proper testing is done through the public APIs.
use super::*;
use crate::codec::{Codec, Cursor};
#[test]
fn capabilities() {
// A capabilities extension with the default values for openmls.
let extension_bytes = [0, 1, 0, 16, 1, 1, 6, 0,... | true |
251e493b0e74acb322e48f01cdbdff40b1026de7 | Rust | chrsep/proto | /src/game_state.rs | UTF-8 | 3,017 | 2.890625 | 3 | [] | no_license | use crate::collision::{
check_bottom_collision, check_left_collision, check_right_collision, check_top_collision,
};
use crate::entity::{Player, Wall};
use tetra::graphics::Color;
use tetra::input::{is_key_down, Key};
use tetra::{graphics, Context, State};
pub struct GameState {
player: Player,
walls: [Wal... | true |
c7325c93c4992bbb394eb9d48bc1fbbae4881d65 | Rust | KMJ192/rust | /rust_grammar/method/src/main.rs | UTF-8 | 1,147 | 4.0625 | 4 | [] | no_license | use std::fmt;
#[derive(Debug)] //Object Struct를 Debug -> {:?}로 println!("{:?}") 출력 가능
struct Object{
width : u32,
height : u32,
}
impl fmt::Display for Object{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result{
write!(f, "({} {})", self.width, self.height)
}
}
//Methods
impl Object{
fn... | true |
896fe2dfaea46d69f84a87eb57c57f29165e892f | Rust | danmarcab/advent-of-code-2019 | /src/day1.rs | UTF-8 | 966 | 3.359375 | 3 | [] | no_license | #[aoc_generator(day1)]
pub fn input_generator(input: &str) -> Vec<u32> {
input
.lines()
.map(|l| l.trim().parse::<u32>().unwrap())
.collect()
}
#[aoc(day1, part1)]
pub fn part1(input: &[u32]) -> u32 {
input.iter().fold(0, |sum, w| sum + (w / 3 - 2))
}
#[aoc(day1, part2)]
pub fn part2(i... | true |
f11769ef7e8d78bf939b6f8532e6a891022f79eb | Rust | iCodeIN/kafka-protocol | /src/client.rs | UTF-8 | 13,767 | 2.6875 | 3 | [] | no_license | use std::{convert::TryFrom, io, mem};
use {
bytes::Buf,
combine::{EasyParser, Parser},
tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt},
};
use crate::{api_key::ApiKey, reserve, Encode, Result};
pub struct Client<I> {
io: I,
buf: Vec<u8>,
correlation_id: i32,
client_id: Opt... | true |
a73fdd03607399c2056607194b3247586dea9bd2 | Rust | ducc/refinery | /refinery_cli/src/cli.rs | UTF-8 | 2,482 | 2.734375 | 3 | [
"MIT"
] | permissive | //! Defines the CLI application
use crate::{APP_NAME, VERSION};
use clap::{App, AppSettings, Arg, SubCommand};
/// Initialise the CLI parser for our app
pub fn create_cli() -> App<'static, 'static> {
/* The setup cmd handles initialisation */
let setup = SubCommand::with_name("setup")
.about("Run the ... | true |
cfa60a3eafc7f9445c8a14ec5859c0e59bcf7546 | Rust | AlbanMinassian/env-lang | /src/struct_envlang_error.rs | UTF-8 | 1,684 | 2.78125 | 3 | [
"MIT"
] | permissive | use std::fmt;
use core::fmt::Display;
use failure::{Backtrace, Context, Fail};
// ------------------------------------------------------------------------------------
// Error
// ------------------------------------------------------------------------------------
#[derive(Debug)]
pub struct EnvLangError {
pub inne... | true |
7618b45a4b4959c2a5da2aeee25f60a0110105d4 | Rust | napi-rs/napi-rs | /crates/napi/src/js_values/boolean.rs | UTF-8 | 776 | 2.65625 | 3 | [
"MIT"
] | permissive | use std::convert::TryFrom;
use super::Value;
use crate::bindgen_runtime::{TypeName, ValidateNapiValue};
use crate::{check_status, ValueType};
use crate::{sys, Error, Result};
#[derive(Clone, Copy)]
pub struct JsBoolean(pub(crate) Value);
impl TypeName for JsBoolean {
fn type_name() -> &'static str {
"bool"
}... | true |
258204b83622753734790a950726ce2c450a732f | Rust | mnts26/aws-sdk-rust | /sdk/resourcegroups/src/model.rs | UTF-8 | 65,479 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>A mapping of a query attached to a resource group that determines the AWS resources
/// that are members of the group.</p>
#[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq)]
pub struct GroupQuery {
/// <p>The na... | true |
8b0db5faa08ffe7998b39cabf0c4df15dd0fca74 | Rust | Polkadex-Substrate/curv | /examples/proof_of_knowledge_of_dlog.rs | UTF-8 | 1,198 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use curv::elliptic::curves::*;
/// Sigma protocol for proof of knowledge of discrete log
/// TO RUN:
/// cargo run --example proof_of_knowledge_of_dlog -- CURVE_NAME
/// CURVE_NAME is any of the supported curves: i.e.:
/// cargo run --example proof_of_knowledge_of_dlog -- jubjub
///
/// notice: this library includes o... | true |
2a5c4b55ce33f8acdbdc93f6c018490b99232e3c | Rust | nikomatsakis/rust | /src/test/run-pass/assign-assign.rs | UTF-8 | 437 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"bzip2-1.0.6",
"BSD-1-Clause"
] | permissive | // Issue 483 - Assignment expressions result in nil
fn test_assign() {
let x: int;
let y: () = x = 10;
assert (x == 10);
let z = x = 11;
assert (x == 11);
z = x = 12;
assert (x == 12);
}
fn test_assign_op() {
let x: int = 0;
let y: () = x += 10;
assert (x == 10);
let z = x +... | true |
42413231510ea4ffe036edc4be5a0be66c93d988 | Rust | rosowskimik/rnu | /src/main.rs | UTF-8 | 2,506 | 2.734375 | 3 | [
"MIT"
] | permissive | use anyhow::bail;
use anyhow::Result;
use clap::{crate_authors, crate_description, crate_version};
use clap::{App, Arg};
use std::{ffi, fs, path::Path};
use uuid::Uuid;
fn main() -> Result<()> {
let matches = App::new("rnu")
.version(crate_version!())
.author(crate_authors!())
.about(crate_... | true |
73ad5a3fedfb4b61300fdc8a7d4bfc1b75c10440 | Rust | YsuOS/atcoder | /gcd_on_blackboard/src/main.rs | UTF-8 | 992 | 3.28125 | 3 | [] | no_license | use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
let stdin = stdin();
let stdin = stdin.lock();
let token: String = stdin
.bytes()
.map(|c| c.expect("failed to read char") as char)
.skip_while(|c| c.is_whitespace())
.take_while(|c| !c.is_whitespace())
... | true |
997a3127b04b7deff98572d01dd9e11c7678385f | Rust | flying7eleven/insomnia-rs | /src/main.rs | UTF-8 | 3,142 | 2.625 | 3 | [] | no_license | use chrono::Local;
use clap::{crate_authors, crate_description, crate_version, Clap};
use log::{error, LevelFilter};
use schlaflosigkeit::commands::annotate::{run_command_annotate, AnnotateCommandOptions};
use schlaflosigkeit::commands::config::{run_command_config, ConfigCommandOptions};
use schlaflosigkeit::commands:... | true |
579eed761e012d47ffc977421f732837f2ed5ccc | Rust | lancelafontaine/coding-challenges | /kattis/planina/rust/planina/src/main.rs | UTF-8 | 834 | 3.15625 | 3 | [] | no_license | use std::io::{self, BufRead, Write};
type Result<T> = std::result::Result<T, Box<std::error::Error>>;
fn main() -> Result<()> {
let stdin = io::stdin();
let stdout = io::stdout();
let stdin_handle = stdin.lock();
let mut stdout_handle = stdout.lock();
const INITIAL_NUM_POINT_ON_SIDE_OF_SQUARE: u32... | true |
35d84fe8eb6dfa308b12b94e4fc926dda2958b76 | Rust | volyx/advent2020-rust | /src/advent9/mod.rs | UTF-8 | 2,049 | 3.234375 | 3 | [] | no_license | use std::fs::File;
use std::io::{prelude::*, BufReader};
pub fn solution() {
let file = File::open("advent9.txt").unwrap();
let reader = BufReader::new(file);
let preamble: usize = 25;
let mut preamble_window = Vec::with_capacity(preamble);
let mut i: usize = 0;
let mut current_index = 0;
l... | true |
bc8233738b1dc99df9951ebe485186fe5b956450 | Rust | EFanZh/LeetCode | /src/problem_0038_count_and_say/mod.rs | UTF-8 | 370 | 3.28125 | 3 | [] | no_license | pub mod iterative;
pub trait Solution {
fn count_and_say(n: i32) -> String;
}
#[cfg(test)]
mod tests {
use super::Solution;
pub fn run<S: Solution>() {
let test_cases = [(1, "1"), (2, "11"), (3, "21"), (4, "1211"), (5, "111221")];
for (n, expected) in test_cases {
assert_eq!(... | true |
99e102335aca705baaa6478ff7e20dd91cb17a91 | Rust | thominspace/aoc_2020 | /day_11/src/main.rs | UTF-8 | 18,962 | 3.1875 | 3 | [] | no_license | use std::time::{Instant};
use std::io::{Error};
use std::fs;
use std::collections::{HashMap};
fn main() -> Result<(), Error> {
// seeing as pretty much every puzzle is going to be reading in a file and then manipulating the input,
// I might as well just build main out to be a template
// read the input ... | true |
dd59f65304ac2936e005f0da39a7259c6f86ac54 | Rust | spacemeshos/svm | /crates/host/types/src/receipt/call.rs | UTF-8 | 2,500 | 3.140625 | 3 | [
"LicenseRef-scancode-free-unknown",
"MIT"
] | permissive | use std::collections::HashSet;
use crate::gas::Gas;
use crate::receipt::{ReceiptLog, RuntimeError};
use crate::{Address, State};
/// Runtime transaction execution receipt
#[derive(Debug, PartialEq, Clone)]
pub struct CallReceipt {
/// Transaction format version.
pub version: u16,
/// Whether transaction ... | true |
b63648ff8b99dd246d75526eb72203cc44575287 | Rust | kevinmehall/rust-peg | /benches/json.rs | UTF-8 | 1,328 | 2.796875 | 3 | [
"MIT"
] | permissive | #![feature(test)]
extern crate peg;
extern crate test;
use test::Bencher;
peg::parser!(grammar parser() for str {
// JSON grammar (RFC 4627). Note that this only checks for valid JSON and does not build a syntax
// tree.
pub rule json() = _ (object() / array()) _
rule _() = [' ' | '\t' | '\r' | '\n']*
rule value_s... | true |
ad3c2fe8745493fe5771faeffb7770ed266090ee | Rust | kapitanov/rust-grep | /src/main.rs | UTF-8 | 1,460 | 2.890625 | 3 | [
"MIT"
] | permissive | use std::env;
use std::io::BufRead;
mod grep;
use crate::grep::*;
fn main() {
let args: Vec<String> = env::args().skip(1).collect();
let config = Config::new(&args).unwrap_or_else(err_handler);
if config.show_help() {
print_help();
return;
}
let runner = config.create_runner();
... | true |
2ec7ed559f417fd142231ff19733adc7434bac4e | Rust | ekupura/clumsy | /src/translator/mod.rs | UTF-8 | 3,323 | 3.34375 | 3 | [
"BSD-2-Clause"
] | permissive | #[cfg(test)]
mod tests;
use parser::ast;
use std::collections::HashMap;
use std::fmt;
use std::fmt::{Display, Formatter};
#[derive(Debug, PartialEq)]
pub enum Expression {
Abstraction {
name: String,
expression: Box<Expression>,
},
Application {
callee: Box<Expression>,
arg... | true |
9a44d10e2c2c47d4e067fc5b5a14a95f7559936c | Rust | zackmdavis/Exercises_A | /Programming_Challenges/5-9-7.rs | UTF-8 | 2,175 | 3.171875 | 3 | [] | no_license |
struct Hardcover {
profitably: uint,
battlements: uint
}
#[allow(unnecessary_parens)]
impl PartialEq for Hardcover {
fn eq(&self, other: &Hardcover) -> bool {
((self.profitably == other.profitably) &&
(self.battlements == other.battlements))
}
}
impl Hardcover {
pub fn perforates... | true |
866072cae025fcf4ade4b5077e0e1e9d4cb3d796 | Rust | Mazisky/rpfm | /rpfm_lib/src/packedfile/ca_vp8/mod.rs | UTF-8 | 13,993 | 2.75 | 3 | [
"MIT"
] | permissive | //---------------------------------------------------------------------------//
// Copyright (c) 2017-2020 Ismael Gutiérrez González. All rights reserved.
//
// This file is part of the Rusted PackFile Manager (RPFM) project,
// which can be found here: https://github.com/Frodo45127/rpfm.
//
// This file is licensed un... | true |
1089929ff5c9993e261a36ef0482659a85c13c73 | Rust | septimochen/rust-algs | /src/graph/open_lock.rs | UTF-8 | 2,492 | 3.3125 | 3 | [] | no_license | use std::collections::HashSet;
pub struct Solution;
#[allow(dead_code)]
impl Solution {
fn plus_one(s: String, j: usize) -> String {
let mut ch: Vec<char> = s.chars().collect();
if ch[j] == '9' {
ch[j] = '0';
} else {
let digit = ch[j].to_digit(10).unwrap() + 1;
... | true |
92c7802b2ef9fd77d51f975e7b8019cc6edc108b | Rust | blck-snwmn/data-structure-rs | /bplus/src/lib.rs | UTF-8 | 8,118 | 3.4375 | 3 | [] | no_license | use std::fmt::Display;
#[derive(Debug)]
pub struct Data<T>
where
T: Display,
{
id: usize,
data: T,
#[allow(dead_code)]
next_id: Option<usize>,
}
impl<T: Display> Data<T> {
pub fn new(id: usize, data: T) -> Self {
Self {
id,
data,
next_id: None,
... | true |
b1ae5212224e148d94eae92130e1874fa6dd5db2 | Rust | isgasho/dragonbox | /src/buffer.rs | UTF-8 | 3,527 | 3.40625 | 3 | [
"LLVM-exception",
"Apache-2.0",
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{Buffer, Float};
use core::mem::MaybeUninit;
use core::slice;
use core::str;
impl Buffer {
/// This is a cheap operation; you don't need to worry about reusing buffers
/// for efficiency.
#[inline]
pub fn new() -> Self {
let bytes = [MaybeUninit::<u8>::uninit(); 24];
Buffer {... | true |
158fec9f07354f8038144d43a456a51bb7206070 | Rust | Hexilee/BronzeDB | /bronzedb-server/src/lib.rs | UTF-8 | 3,124 | 2.828125 | 3 | [
"MIT"
] | permissive | use bronzedb_engine::Engine;
use bronzedb_protocol::request::Request::{self, *};
use bronzedb_protocol::response::Response;
use bronzedb_util::status::StatusCode::*;
use bronzedb_util::status::{Error, Result};
use log::info;
use std::io::ErrorKind;
use std::net::{TcpListener, TcpStream};
use std::thread::spawn;
pub st... | true |
dc3ed88653629f07f2365014b95ceee4635fcd9b | Rust | MalteT/thermal-printer-bots | /shopping-bon-bot/src/state.rs | UTF-8 | 4,325 | 2.984375 | 3 | [
"MIT"
] | permissive | use telegram_bot::{CanSendMessage, User};
use tracing::error;
use std::fmt;
use crate::{
bot::TelegramBot,
settings::{Role, SETTINGS},
storage::{CategoryDB, ItemDB},
Command, CommandKind, ResultExt,
};
/// Assembly of all relevant items
pub struct State {
pub bot: TelegramBot,
pub itemdb: Ite... | true |
fdd2dded5e9a01f9c3377cb4978b8b12ea44d84b | Rust | tetris-hermetris/sound-garden-0x2 | /audio_ops/src/channel.rs | UTF-8 | 378 | 2.71875 | 3 | [
"MIT"
] | permissive | use audio_vm::{Op, Stack, CHANNELS};
pub struct Channel {
channel: usize,
}
impl Channel {
pub fn new(channel: usize) -> Self {
Channel { channel }
}
}
impl Op for Channel {
fn perform(&mut self, stack: &mut Stack) {
let mut frame = [0.0; CHANNELS];
frame[self.channel] = stack... | true |
229ca75fc5e72510ad16342add095f0406134047 | Rust | caiocampos/Rust-Random-Stuff | /variable-length-quantity.rs | UTF-8 | 1,798 | 3.625 | 4 | [
"MIT"
] | permissive | #[derive(Debug, PartialEq)]
pub enum Error {
IncompleteNumber,
Overflow,
}
const SHIFT: u8 = 7;
const FLAG: u8 = 0x80;
const MAX: u64 = 0xFFFF_FFFF;
fn get_bases(val: u64) -> (u8, u64) {
let mut shift: u8 = 28;
let mut base: u64 = 0x7_F000_0000;
loop {
if (val & base) == 0 {
sh... | true |
e17c34f0fb771063f8c3cbd3c8765c8d0e1a010c | Rust | rust-lang/rust-analyzer | /crates/hir-expand/src/builtin_derive_macro.rs | UTF-8 | 28,931 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Builtin derives.
use ::tt::Ident;
use base_db::{CrateOrigin, LangCrateOrigin};
use itertools::izip;
use mbe::TokenMap;
use rustc_hash::FxHashSet;
use stdx::never;
use tracing::debug;
use crate::{
name::{AsName, Name},
tt::{self, TokenId},
};
use syntax::ast::{self, AstNode, FieldList, HasAttrs, HasGeneric... | true |
dbe045e525dbb3c6ff477b7f2203cca21b38061c | Rust | frankegoesdown/LeetCode-in-Go | /Algorithms/0324.wiggle-sort-ii/wiggle-sort-ii_test.go | UTF-8 | 770 | 2.53125 | 3 | [
"MIT"
] | permissive | package problem0324
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
// tcs is testcase slice
var tcs = []struct {
nums []int
}{
{[]int{1, 5, 1, 1, 6, 4}},
{[]int{1, 3, 2, 2, 3, 1}},
// 可以有多个 testcase
}
func check(nums []int) bool {
for i := 0; i < len(nums); i += 2 {
if 0 <= i-1 && nums[... | true |
d2c2c6610b98fb53cdf1b0c9ca6cc6feabb10437 | Rust | dunnock/grayarea | /grayarea-sdk/src/memory.rs | UTF-8 | 900 | 2.53125 | 3 | [] | no_license | // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
// TODO: rewrite messages exchange to interface types rather than mem buffer
// Create a static mutable byte buffer.
... | true |
420f6ce1421dd8b44239c0544d4b4ec76882b70e | Rust | dimforge/nalgebra | /nalgebra-glm/src/gtx/rotate_normalized_axis.rs | UTF-8 | 1,017 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | use na::{Rotation3, Unit, UnitQuaternion};
use crate::aliases::{Qua, TMat4, TVec3};
use crate::RealNumber;
/// Builds a rotation 4 * 4 matrix created from a normalized axis and an angle.
///
/// # Parameters:
///
/// * `m` - Input matrix multiplied by this rotation matrix.
/// * `angle` - Rotation angle expressed in ... | true |
b327e217fa6d93309fd5ff19aa1c9bd543204a8f | Rust | bluk/advent_of_code | /aoc_2019_6/src/main.rs | UTF-8 | 654 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use std::io::{self};
use aoc_2019_6::{self, error::Error, OrbitMap};
fn main() -> Result<(), Error> {
let mut orbit_map = OrbitMap::new();
loop {
let mut input = String::new();
let bytes_read = io::stdin().read_line(&mut input)?;
if bytes_read == 0 {
break;
}
... | true |
46127eba6534578470ed1694ed99a17ba26ae282 | Rust | Ax9D/RandomExperiments | /rust/ecstest/src/main.rs | UTF-8 | 2,024 | 3.328125 | 3 | [] | no_license | #![allow(non_snake_case)]
use std::{any::{Any, TypeId}, cell::UnsafeCell, collections::HashMap};
use anymap::AnyMap;
struct Entity{
id:usize
}
trait Component{
fn update(&self);
}
struct EngineContext {
engine: UnsafeCell<Engine>
}
struct BoundingBox {
}
struct CameraFollow {
}
impl Component for BoundingBox {
... | true |
a0968728d91ee85e267f325b73286d076efad78c | Rust | andrewgoacher/advent_of_code_2018 | /src/day_1.rs | UTF-8 | 2,696 | 3.515625 | 4 | [] | no_license | mod util;
use std::collections::HashMap;
use util::{get_lines, get_file_path};
pub fn part_1(path: &String) -> i32 {
get_lines(path)
.into_iter()
.map(|x| x.parse::<i32>().unwrap())
.sum()
}
pub fn part_2(path: &String) -> i32 {
let lines = get_lines(path);
internal_solve_proper(&... | true |
a828f6128ae2813a8095f8b3d30fb0e97435ab36 | Rust | appaquet/exocore | /protos/src/error.rs | UTF-8 | 674 | 2.515625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use super::reflect::FieldId;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Message type is not in registry: {0}")]
NotInRegistry(String),
#[error("Field doesn't exist: {0}")]
NoSuchField(FieldId),
#[error("Invalid field type")]
InvalidFieldType,
#[error("Field type not sup... | true |
791abe8421375c170a6f4ec4d4a03099d429c826 | Rust | jkarns275/stdgba | /src/graphics/sprites.rs | UTF-8 | 9,378 | 2.90625 | 3 | [
"MIT"
] | permissive | use core::mem::transmute;
use collections::StaticArr;
use ptr::Ptr;
use graphics::*;
/// Further documentation sprite related gba things can be found here: https://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm#Graphics%20Hardware%20Overview
/// and also here: https://www.coranac.com/tonc/text/regobj.htm
pub const ... | true |
918aa4d1d7aa7cc7a0d41e2b4a0f120b51f12cab | Rust | BHouwens/cryptofun | /src/utils/transform.rs | UTF-8 | 2,283 | 3.484375 | 3 | [] | no_license | /// Flattens an array of chunk tuples that contain
/// chunk slice data
///
/// ### Arguments
///
/// * `input` - Input to flatten
pub fn flatten_chunks_with_chunk_data<T: Clone>(input: &Vec<(T, Vec<u8>)>) -> (Vec<T>, Vec<u8>) {
let size = input.iter().fold(0, |a, b| a + b.1.len());
let recoded_bytes = ... | true |
b1ed9fb1c93fe75f7d731c9873c3ea28b6f9b5e3 | Rust | vovac12/yatir | /core/src/error.rs | UTF-8 | 476 | 2.921875 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum CoreError {
NotFound(String),
NotImplemented(String),
InternalError,
}
impl CoreError {
pub fn internal_error() -> Self {
Self::InternalError
}
pub fn not_implemented(msg: impl Into<String>) ... | true |
c7efc74c4110836cbe7d20d29505c08a6bb2c58c | Rust | jonasbb/exercism | /rust/circular-buffer/src/lib.rs | UTF-8 | 2,006 | 3.578125 | 4 | [
"Unlicense"
] | permissive | #![allow(unknown_lints)]
pub type BufferResult<T> = Result<T, Error>;
#[derive(Debug,PartialEq,Eq)]
#[allow(enum_variant_names)]
pub enum Error {
EmptyBuffer,
FullBuffer,
}
pub struct CircularBuffer<T> {
// size is always 1 larger than requested. This 1 element is used to distinguish between full
// ... | true |
9baec97f5f11940fdf8982a224303251ce95a7eb | Rust | nativesintech/nit-slack-analytics | /src/members.rs | UTF-8 | 4,668 | 3.1875 | 3 | [
"MIT"
] | permissive | mod members_struct {
use crate::util::slack::parse_slack_date;
use chrono::{prelude::*, Datelike};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
pub struct MembersData {
pub total_members: u32,
pub joined_this_year: u32,
pub joined_by_year: HashMap<i32,... | true |
5273008d9d523b092627739ef88961b72a933efa | Rust | zhutony/convey | /src/config.rs | UTF-8 | 5,677 | 3 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::fs::File;
use std::io::{Read, Error as IOError};
use std::result::Result;
use std::sync::mpsc::{Receiver};
use std::thread;
use notify::{RecommendedWatcher, Watcher, RecursiveMode};
use std::sync::mpsc::channel;
use std::time::Duration;
use toml;
#[derive(Debug, Clone)]
pub stru... | true |
6517c77739341420bdab0676fffa41bfe03ca394 | Rust | Incomprehensible/Rust-projects | /process_management/simple_process/src/main.rs | UTF-8 | 2,118 | 2.84375 | 3 | [] | no_license | pub extern crate libc;
use std::process::exit;
use std::thread::sleep;
use std::time::Duration;
use libc::c_void;
use libc::sigaction;
use nix::sys::signal::sigaction;
use nix::sys::wait::waitpid;
use nix::unistd::{fork, getpid, getppid, ForkResult};
use libc::{_exit, STDOUT_FILENO, write};
extern "C" fn handle_sigc... | true |
2870a6f533f102babd86761eb69fb0865293b976 | Rust | tcsc/raygun | /lib/raygun-scene/src/lib.rs | UTF-8 | 1,968 | 2.765625 | 3 | [] | no_license | use std::sync::Arc;
use raygun_camera::Camera;
use raygun_material::{Colour, COLOUR_BLACK};
use raygun_math::{Ray, Transform};
use raygun_primitives::{Object, Visitor};
///
/// The toplevel owner of all objects and lights
///
pub struct Scene {
pub objects: Vec<Arc<Object>>,
pub camera: Camera,
}
pub struct ... | true |
58811d4d3ff216c4daaf45e97f95c4202ec83e14 | Rust | BlockCat/raytrazor | /src/material.rs | UTF-8 | 863 | 2.84375 | 3 | [] | no_license | use ggez::{
graphics::{Color, Image},
nalgebra::Vector3,
};
#[derive(Debug, Clone)]
pub enum Materials {
Color(Color),
Image(Image),
}
#[derive(Debug, Clone)]
pub struct Material {
refractive: f32,
pub reflective: f32,
map: Materials,
}
impl Material {
pub fn color(col: Color) -> Mate... | true |
0d8ff95eb46ad7cfd0dc25aecfda460dd85adecc | Rust | joehattori/rslog | /src/main.rs | UTF-8 | 1,203 | 2.53125 | 3 | [] | no_license | pub mod app;
pub mod expr;
pub mod parser;
pub mod unifier;
pub mod util;
use std::io::{stdin, stdout, Write};
use crate::app::{App, Status};
use crate::expr::Term;
use crate::unifier::search;
const PROMPT: &'static str = "?- ";
const HALT_MESSAGE: &'static str = "halt.";
fn main() {
let mut app = App::new();
... | true |
3476c7c798c25c31b345ee4c1d224c951346c5de | Rust | neoeinstein/cj4-fadec | /wt_systems/src/pid/wescott.rs | UTF-8 | 14,151 | 2.59375 | 3 | [] | no_license | //! PID implementation based on the the model described by Tim Wescott
//!
//! Follows the model described in the free [_PID Without a Ph. D._][Wes18]
//! authored by Tim Wescott.
//!
//! [Wes18]: https://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pdf
use super::{Derivative, ErrorRate, Integral, PidComponents... | true |
e387424f33461fc56cce01a01efb2d0667d2737e | Rust | whiteCcinn/learn-rust-basic | /src/e_tuple/let_bind.rs | UTF-8 | 454 | 3.3125 | 3 | [] | no_license | // 元祖内元素的可选绑定与不可选绑定
#[allow(unused_variables, dead_code)]
pub fn handle() {
// 元祖
// => a 不可变绑定
// => b 可变绑定
let (a, mut b): (bool,bool) = (true, false);
println!("a = {:?}, b = {:?}", a, b);
// a 不可变绑定
// a = false; // error: cannot assign twice to immutable variable `a`
// b 可变绑定
... | true |
4eba40aeaad85c60a620ae0634c87b19dcdd4bb8 | Rust | polymny/ergol | /examples/query/src/main.rs | UTF-8 | 2,266 | 3.109375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use ergol::prelude::*;
use ergol::tokio;
use ergol::tokio_postgres::{Error, NoTls};
#[rustfmt::skip]
#[ergol]
pub struct User {
#[id] pub id: i32,
#[unique] pub username: String,
#[unique] pub email: String,
pub age: i32,
}
#[rustfmt::skip]
#[ergol]
pub struct Project {
#[id] pub id: i32,
pub ... | true |
fd71ff240a757eba680495783fb18cf3273741b3 | Rust | noirotm/advent-of-code-2018 | /build.rs | UTF-8 | 2,424 | 2.84375 | 3 | [
"MIT"
] | permissive | // generate file that dynamically instanciates all solutions
use chrono::prelude::*;
use std::error::Error;
use std::fs;
use std::fs::read_dir;
use std::fs::File;
use std::io;
use std::io::Write;
use std::path::Path;
use std::str;
fn days(input_dir: &str) -> io::Result<Vec<u32>> {
Ok(read_dir(input_dir)?
.... | true |
11376d2d1a750401f3fe9077909e2eb7d8007808 | Rust | JamesMcGuigan/ecosystem-research | /wasm/js-canvas/rust/src/canvas.rs | UTF-8 | 1,909 | 2.828125 | 3 | [
"MIT"
] | permissive | use wasm_bindgen::prelude::*;
// DOCS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory
// DOCS: https://wasmbyexample.dev/examples/webassembly-linear-memory/webassembly-linear-memory.rust.en-us.html
const CANVAS_MAX_HEIGHT: usize = 1920;
const CANVAS_MAX_WIDTH: usiz... | true |
e12730310adc51696a77d49858eff3d39e6e7788 | Rust | gvassallo/rust-x11-window-manager | /x11/src/methods.rs | UTF-8 | 27,315 | 2.640625 | 3 | [] | no_license | //! More backend methods.
use std::borrow::Cow;
use std::collections::HashMap;
use std::convert::From;
use std::env;
use std::ffi::{CStr, CString};
use std::fs;
use std::mem::{transmute, zeroed};
use std::os::raw::{c_int, c_long, c_uchar, c_uint, c_ulong};
use std::slice;
use std::sync::Mutex;
use cplwm_api::types::{... | true |
02f80fafc73c82d17eb1478ca4910b190595f213 | Rust | wa7sa34cx/nag | /src/agenda/time_parsing/tests.rs | UTF-8 | 6,178 | 2.625 | 3 | [
"MIT"
] | permissive | use chrono::{Duration, TimeZone};
use clap::Clap;
use crate::Opts;
use super::{Cronline, parse_cronline};
#[test]
fn fixed_durations() {
let now = chrono::Local.ymd(2000, 01, 01).and_hms(08, 00, 00);
test_parse(&TestParams::new(
now,
"in 2 min test1 test2",
Cronline::from_time(&(now ... | true |
fef8853917f120a94654348cb4bd21086404cb3e | Rust | BigTuna08/par_lgp2 | /src/anal/oldmod.rs | UTF-8 | 6,060 | 2.53125 | 3 | [] | no_license |
use evo_sys::*;
use data::DataSet;
use std::collections::HashMap;
use params;
pub struct DecompSet{
pub branches: Vec<Instruction>,
pub progs: Vec<Program>,
pub original: Program,
// pub sample_paths: Vec<String>,
}
pub struct SomeResult{
correct: u16,
n: u16,
fpos: u16,
... | true |
5206b4489580d2a111f8b50c519139f34079d83c | Rust | pliniker/eval-rs | /src/repl.rs | UTF-8 | 2,470 | 2.921875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::compiler::compile;
use crate::error::{ErrorKind, RuntimeError};
use crate::memory::{Mutator, MutatorView};
use crate::parser::parse;
use crate::safeptr::{CellPtr, TaggedScopedPtr};
use crate::vm::Thread;
/// A mutator that returns a Repl instance
pub struct RepMaker {}
impl Mutator for RepMaker {
type ... | true |
dfe54f4c40174b62050b645b420dbad863863fcc | Rust | edkins/waproof | /lang-stuff/src/lib.rs | UTF-8 | 6,438 | 3.03125 | 3 | [] | no_license | use nom::IResult;
use nom::branch::alt;
use nom::bytes::complete::{tag,take_until,take_while};
use nom::character::complete::{digit1,multispace1,satisfy};
use nom::combinator::{map,opt,recognize,value};
use nom::error::{ErrorKind, ParseError};
use nom::multi::many0;
use nom::sequence::{pair,preceded};
use num_bigint::B... | true |
4d0db718bbe5540cd470f4b75c2e25bf1b0c240c | Rust | SuperiorJT/twilight | /http/src/request/channel/webhook/update_webhook_message.rs | UTF-8 | 17,020 | 3.078125 | 3 | [
"ISC"
] | permissive | //! Update a message created by a webhook via execution.
use crate::{
client::Client,
error::Error as HttpError,
request::{
self,
validate_inner::{self, ComponentValidationError, ComponentValidationErrorType},
AuditLogReason, AuditLogReasonError, Form, NullableField, Request,
},... | true |
6bad9619e9211b85b06d3f5086d9cd7d1d87b6c6 | Rust | jmageau/advent_of_code | /src/year_2016/day_6.rs | UTF-8 | 1,437 | 3.109375 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
pub fn answers() -> String {
format!("{}, {}", answer_one(), answer_two())
}
fn answer_one() -> String {
decrypt_message(true)
}
fn answer_two() -> String {
decrypt_message(false)
}
fn decrypt_message(use_max: bool) -> String {
... | true |
89740b75ad9009ff1af5d62758cdd8de6e2aee61 | Rust | himlpplm/rust-tdlib | /src/types/get_message_embedding_code.rs | UTF-8 | 2,621 | 2.859375 | 3 | [
"MIT"
] | permissive | use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
/// Returns an HTML code for embedding the message. Available only for messages in supergroups and channels with a username
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct GetMessageEmbeddingCode {
#[doc(hidden)]
#[serde(rename(seri... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.