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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
34e9697ce3bacbb5bde737790d1c62edfd22d730 | Rust | rickyclarkson/advent-of-code-2020 | /src/common_io.rs | UTF-8 | 287 | 2.796875 | 3 | [
"BSD-3-Clause"
] | permissive | pub fn read_a_file(filename: &str) -> std::io::Result<Vec<String>> {
use std::fs::File;
use std::io::{self, BufRead, BufReader};
let file = File::open(filename)?;
let file_reader = BufReader::new(file);
Ok(file_reader.lines().filter_map(io::Result::ok).collect())
}
| true |
dea18120ed34261a262f60e9373424c726bba54d | Rust | cginternals/yage | /yage-core/src/core/render.rs | UTF-8 | 3,225 | 3.546875 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | use cgmath::Vector4;
use crate::Context;
use crate::GpuObject;
use crate::Update;
///
/// Represents a component that executes rendering or other GPU-based computation code.
///
/// A `Render` object can be moved into a [`Canvas`] to control what is rendered onto
/// the screen. But `Render` objects can also be used ... | true |
2b2e8a2695f01f3a2c8b6916db290ea019133059 | Rust | themadprofessor/taps | /src/resolve.rs | UTF-8 | 985 | 2.890625 | 3 | [
"MIT"
] | permissive | use async_trait::async_trait;
use snafu::Snafu;
use std::error::Error as StdError;
use std::marker::Send as StdSend;
use std::net::SocketAddr;
use tokio::task;
#[derive(Debug, Snafu)]
#[snafu(visibility = "pub(crate)")]
pub enum Error {
#[snafu(display("missing endpoint"))]
MissingEndpoint,
#[snafu(displa... | true |
efe47e9b70a7b25b2087a87fc9d981502b4c898f | Rust | zrma/1d1rust | /src/boj/p20k/p20365.rs | UTF-8 | 1,988 | 3.109375 | 3 | [] | no_license | use crate::utils::io::read_line;
use std::io::{BufRead, Write};
#[allow(dead_code)]
fn solve20365(reader: &mut impl BufRead, writer: &mut impl Write) {
read_line(reader);
let chars = read_line(reader).chars().collect::<Vec<_>>();
let mut r_count = 0;
let mut b_count = 0;
let mut prev = ' ';
c... | true |
23a88d75f1af3f8bb885759b62809648b4d0c144 | Rust | BonsaiDen/td-shooter-rs | /client/src/effect/laser_beam_hit.rs | UTF-8 | 2,004 | 2.609375 | 3 | [] | no_license | // External Dependencies ------------------------------------------------------
use clock_ticks;
use graphics::Transformed;
// Internal Dependencies ------------------------------------------------------
use ::camera::Camera;
use ::renderer::{Renderer, Circle};
use ::effect::{Effect, ParticleSystem, particle};
use sh... | true |
7ddbc3bcb3e819a7e44eaaee7a4071d5d4f78910 | Rust | sharlotta93/track_it | /src/person.rs | UTF-8 | 1,905 | 3.484375 | 3 | [] | no_license | mod record;
use record::Record;
use std::vec::Vec;
#[derive(Debug)]
struct User {
username: String,
email: String,
active: bool,
user_records: Vec<Record>,
}
impl User {
fn build_user(email: String, username: String) -> User {
User {
email,
username,
ac... | true |
bb8b5fd4430499e734e2a7992d3b3df70a0fd043 | Rust | badboy/murmurhash64-rs | /src/hasher.rs | UTF-8 | 3,933 | 3.46875 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::default::Default;
use std::hash::Hasher;
use rand::{self,Rng};
use super::murmur_hash64a;
use std::hash::BuildHasher;
/// MurmurHash2 can also be used as the hash algorithm in a HashMap
/// (or similar).
/// It implements the necessary traits.
///
/// The new hasher traits are only available since Rust 1.7.0
... | true |
5ed346afef7301c144e0f5ebfcf0fb424f440f15 | Rust | rsstdd/rust_cookbook | /ch_02_advanced_programming/05_decisions/descisions.rs | UTF-8 | 534 | 3.1875 | 3 | [] | no_license | // Rust Does not provider automatic Type Casting
// - pattern, mutablilty, scope, and shadow
use std::{i32};
fn main() {
println!("***\nCondition\n*** \n");
let age: i32 = 10;
// If/else
if age <= 18 {
println!("Go to School");
println!("---- \n");
} else if (age > 18) && (age <= ... | true |
95926217314f21a4f59c5b657f6d3e03435ddc1a | Rust | grenewode/tiny-multihash | /examples/custom_table.rs | UTF-8 | 3,992 | 3.375 | 3 | [
"MIT"
] | permissive | use std::convert::TryFrom;
use tiny_multihash::derive::Multihash;
use tiny_multihash::typenum::{U20, U25};
use tiny_multihash::{
Digest, Error, Hasher, Multihash as DefaultMultihash, MultihashDigest, RawMultihash,
Sha2Digest, Sha2_256, StatefulHasher,
};
// The Multihash code is independent of whether the has... | true |
161b5335868e1178ee62fa5d04ff0003dabfb1ac | Rust | Chapmip/wsconvert-rust | /src/ws_file.rs | UTF-8 | 1,845 | 3.40625 | 3 | [
"MIT"
] | permissive | //! Module to process input file to output file via temporary file
use crate::asciify;
use crate::ws_filters;
use std::fs::{File, OpenOptions};
use std::io::{self, BufReader, BufWriter, Read, Seek, SeekFrom, Write};
/// Attempts to convert a WordStar file from the input filename
/// (or `stdin` if empty) to a new Uni... | true |
d51d3a4d2dd1790702e5adfdbfb0b3abe28fb1d0 | Rust | sdee/myxogast | /src/tree.rs | UTF-8 | 12,424 | 2.6875 | 3 | [] | no_license | extern crate serde_json;
//use std::fmt::Write;
use std::io::Write;
use std::collections::BTreeMap;
use self::serde_json::Value as JSON_Val;
use seq::*;
use align::*;
use matrix::*;
use std::iter::Iterator;
use std::rc::Rc;
use std::cmp::max;
#[derive(Debug, Clone)]
pub enum SeqNode {
Nil,
Frag {
id:... | true |
d1c679efc32936c3f22085eace082130d8864186 | Rust | sonhs99/RustyOS2 | /src/arch/x86/src/page.rs | UTF-8 | 2,203 | 2.609375 | 3 | [] | no_license | #![allow(non_snake_case)]
#![allow(dead_code)]
const PAGE_FLAGS_P : u32 = 0x00000001;
const PAGE_FLAGS_RW : u32 = 0x00000002;
const PAGE_FLAGS_US : u32 = 0x00000004;
const PAGE_FLAGS_PWT : u32 = 0x00000008;
const PAGE_FLAGS_PCD : u32 = 0x00000010;
const PAGE_FLAGS_A : u32 = 0x00000020;
const PA... | true |
6ef3c5d772f0f3c8c3b7398a09900fbc77809321 | Rust | johnhurt/four-fours | /four-fours-core/src/math/evaluable.rs | UTF-8 | 30,333 | 2.984375 | 3 | [] | no_license |
use std::fmt;
use std::fmt::{Debug, Display, Formatter};
use math::Number;
use num::{
BigUint,
One,
ToPrimitive,
Integer
};
use statrs::function::gamma::gamma;
impl Debug for EvalFunc {
fn fmt(&self, format: &mut Formatter) -> fmt::Result {
match *self {
EvalFunc::Factorial(ref inner) => write!... | true |
5285f2d43a635aa1b391d926424de369e2225e64 | Rust | the7winds/rust-raytracer | /src/my_mod/camera.rs | UTF-8 | 1,713 | 3 | 3 | [] | no_license | use glam::Vec3;
use crate::my_mod::angle::Angle;
use crate::my_mod::ray::Ray;
use crate::my_mod::utils::random_in_unit_disk;
#[derive(Debug)]
pub struct Camera {
origin: Vec3,
lower_left_corner: Vec3,
horizontal: Vec3,
vertical: Vec3,
lens_radius: f32,
x: Vec3,
y: Vec3,
}
impl Camera {
... | true |
109309c6d4ba72524bae40e395c9e0cc46e5a180 | Rust | ticky/coloursum | /src/ecoji_line.rs | UTF-8 | 2,496 | 3.46875 | 3 | [
"MIT"
] | permissive | use std::convert::From;
use std::fmt;
use std::fmt::Display;
use std::iter::FromIterator;
use itertools::Itertools;
use crate::base_line::{FormattableLine, Line};
#[derive(Debug)]
/// Line with Ecoji base-1024 emoji encoding.
pub struct EcojiLine(FormattableLine);
impl From<String> for EcojiLine {
fn from(conten... | true |
918dee58079c3a9f5b6d0043c4205574a3b6eaf3 | Rust | fan-tom/stream-unconsume | /src/lib.rs | UTF-8 | 6,969 | 3.609375 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! Poll stream partially and get emitted items back!
//! Sometimes it is useful to let someone poll you stream but be able to get it back as if it was never polled.
//! To do so, this crate provides function `remember`, that, given stream, returns tuple of future and stream.
//! You can move returned stream to any fu... | true |
3f94158f77ce070f38283077299c5c1ebd09c040 | Rust | Pslydhh/futures-rs | /futures-util/src/future/with_executor.rs | UTF-8 | 1,018 | 2.796875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::mem::PinMut;
use futures_core::{Future, Poll};
use futures_core::task;
use futures_core::executor::Executor;
/// Future for the `with_executor` combinator, assigning an executor
/// to be used when spawning other futures.
///
/// This is created by the `Future::with_executor` method.
#[derive(Debug)]
#[must... | true |
6f0f09c161d3527a29268ccf24873eedc9f55aac | Rust | jungbin-kwon/tokenizer | /src/analyzer.rs | UTF-8 | 16,083 | 2.796875 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use fst::Set;
use once_cell::sync::Lazy;
use crate::detection::is_latin;
use crate::normalizer::{
ControlCharacterRemover, DeunicodeNormalizer, LowercaseNormalizer, Normalizer,
};
use crate::processors::{
ChineseTranslationPreProcessor, IdentityPreProcessor, PreProcessor, Proces... | true |
7f1b88f3fd7e27188bfe71a1e4b0bdb722fcdbdb | Rust | howe1110/enode | /src/net/system.rs | UTF-8 | 1,567 | 2.984375 | 3 | [] | no_license | use std::net::SocketAddr;
use std::sync::mpsc::{self, Receiver, SyncSender};
use std::sync::Arc;
use std::sync::Mutex;
use std::thread;
use crate::framework::{Notify, System, World};
use crate::net::{Node, NodeEvent};
pub struct NetSystem {
pub sender: SyncSender<NodeEvent>, //node_shell->worker.
receiver: O... | true |
0b60719c6024657045124eb68fd5e23f3afbeac2 | Rust | indirect/matasano_challenges | /vendor/crypto/src/cbc.rs | UTF-8 | 3,684 | 3.1875 | 3 | [] | no_license | extern crate xor;
use std::slice::SliceExt;
use ecb;
use self::xor::Xor;
pub fn decrypt(key: &[u8], iv: &[u8], bytes: &[u8]) -> Vec<u8> {
// we can only decrypt ciphertext composed of 16 byte blocks
assert_eq!(0, bytes.len() % 16);
let mut result: Vec<u8> = Vec::with_capacity(bytes.len());
let mut pr... | true |
db361237f4b7bb97d8dcba3f2f1bfc08e49296a2 | Rust | enzious/diff2html | /src/printers/page.rs | UTF-8 | 1,867 | 2.65625 | 3 | [] | no_license | use crate::config::Diff2HtmlConfig;
use crate::parse;
use crate::printers::{FileListPrinter, LineByLinePrinter, SideBySidePrinter};
static CSS: &'static str = include_str!("../templates/css.hbs");
pub struct PagePrinter {
config: Diff2HtmlConfig,
}
impl PagePrinter {
pub fn new(config: Diff2HtmlConfig) -> Pa... | true |
746b12eb0ba34947d4871d24355293db32556716 | Rust | vadhri/exercism-rust | /circular-buffer/src/lib.rs | UTF-8 | 1,236 | 3.484375 | 3 | [] | no_license | #[derive(Debug, PartialEq, Clone)]
pub struct CircularBuffer <T> {
capacity: usize,
buffer: Vec<T>
}
#[derive(Debug, PartialEq)]
pub enum Error {
EmptyBuffer,
FullBuffer,
}
impl<T: std::clone::Clone + std::fmt::Debug> CircularBuffer<T> {
pub fn new(capacity: usize) -> Self {
let vector: Ve... | true |
5b2f17432d6570a65f3053a217527e702fbc13aa | Rust | gurry/efi | /src/net/addr.rs | UTF-8 | 49,374 | 2.875 | 3 | [
"MIT"
] | permissive | use ffi::{EFI_IPv4_ADDRESS, EFI_IPv6_ADDRESS, EFI_IP_ADDRESS};
use core::{mem, fmt, iter, slice, option, cmp::Ordering};
use crate::io;
use alloc::{string::String, vec::{self, Vec}};
use super::dns::lookup_host;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Ipv4Addr(EFI_IPv4_ADDRESS);
impl Ipv4Addr {
pu... | true |
1c7d76068a8d0e1047c98a5d2abc471316792a90 | Rust | samueltangz/rust-etcd | /src/lease/client.rs | UTF-8 | 2,283 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::sync::Arc;
use futures::{Future, Sink, Stream};
use crate::client::Inner;
use crate::lease::{
GrantRequest, GrantResponse, KeepAliveRequest, KeepAliveResponse, RevokeRequest,
RevokeResponse, TtlRequest, TtlResponse,
};
use crate::Error;
#[derive(Clone)]
pub struct LeaseClient {
inner: Arc<Inner>... | true |
698b4de3757132cbb16b5ad72a5dc946fd286c25 | Rust | plaflamme/mdbook-plantuml | /src/plantumlconfig.rs | UTF-8 | 1,941 | 3.15625 | 3 | [
"MIT"
] | permissive | /// The configuration options available with this backend.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
pub struct PlantUMLConfig {
/// By default it is assumed plantuml.jar is on the path
/// Use plantuml_cmd if it is not on the path, or if you
/// have some ... | true |
ab4b32f0231aff5c2ce68813332a918784d6e4ee | Rust | provable-things/ptokens-core | /src/metadata/metadata_version.rs | UTF-8 | 1,808 | 3.1875 | 3 | [] | no_license | #[cfg(test)]
use strum::IntoEnumIterator;
use strum_macros::EnumIter;
#[cfg(test)]
use crate::types::Result;
use crate::types::{Byte, Bytes};
#[derive(Clone, Debug, PartialEq, Eq, EnumIter)]
pub enum MetadataVersion {
V1,
}
impl MetadataVersion {
pub fn to_byte(&self) -> Byte {
match self {
... | true |
4e113a9617b88a0cdbd9d8c423c08e392ba3bf5f | Rust | michaelfairley/adventofcode2016 | /src/bin/14b.rs | UTF-8 | 1,237 | 2.734375 | 3 | [] | no_license | extern crate crypto;
use crypto::digest::Digest;
use std::collections::HashMap;
// const INPUT: &'static[u8] = b"abc";
const INPUT: &'static[u8] = b"qzyelonm";
fn main() {
let mut md5 = ::crypto::md5::Md5::new();
let mut hash = |n: i32| -> String {
md5.reset();
md5.input(INPUT);
md5.input_str(&n.to_... | true |
a4897462d33d271bb2b864fe6fa5bf2d2a83add1 | Rust | sfackler/rust-openssl | /openssl/src/pkey_ctx.rs | UTF-8 | 31,756 | 2.828125 | 3 | [
"MIT",
"Apache-2.0",
"OpenSSL",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows"
] | permissive | //! The asymmetric encryption context.
//!
//! # Examples
//!
//! Encrypt data with RSA
//!
//! ```
//! use openssl::rsa::Rsa;
//! use openssl::pkey::PKey;
//! use openssl::pkey_ctx::PkeyCtx;
//!
//! let key = Rsa::generate(4096).unwrap();
//! let key = PKey::from_rsa(key).unwrap();
//!
//! let mut ctx = PkeyCtx::new(&... | true |
7d76b0087a8b45b5b406dc78f2282375267ad93c | Rust | denoland/deno_lint | /src/rules/no_octal.rs | UTF-8 | 1,859 | 2.84375 | 3 | [
"MIT"
] | permissive | // Copyright 2020-2021 the Deno authors. All rights reserved. MIT license.
use super::{Context, LintRule};
use crate::handler::{Handler, Traverse};
use crate::Program;
use deno_ast::view::Number;
use deno_ast::SourceRanged;
use once_cell::sync::Lazy;
use regex::Regex;
#[derive(Debug)]
pub struct NoOctal;
const CODE: ... | true |
0942039235394f6ab466911c67cbe096756a596d | Rust | c650/leetcode | /prison-cells-after-n-days.rs | UTF-8 | 2,020 | 3 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
fn encode(cells: &Vec<i32>) -> i32 {
let mut ret = 0;
for (i, e) in cells.iter().enumerate() {
ret |= (e << i);
}
ret
}
fn proceed(cells: &Vec<i32>) -> Vec<i32> {
let mut ans = vec![0; cells.len()];
for i in 1..=(ans.len()-2) {
if (cells[i-1] == ... | true |
7f05c0097ed41381255b646dc9a78b72e2677878 | Rust | apoelstra/cast.rs | /src/lib.rs | UTF-8 | 9,309 | 3.46875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Checked scalar casting
//!
//! # Examples
//!
//! ```
//! extern crate cast;
//!
//! use cast::From;
//!
//! # fn main() {
//! // Infallible operations, like integer promotion, are equivalent to an `as` call
//! assert_eq!(u16::from(0u8), 0u16);
//!
//! // Everything else will return an `Option` depending on the su... | true |
603112c82bef3eb97cc225c2cf675af7e090a4e7 | Rust | raygon-renderer/thermite | /crates/thermite/src/backends/avx1/vu32.rs | UTF-8 | 10,047 | 2.59375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::*;
decl!(u32x8: u32 => __m256i);
impl<S: Simd> Default for u32x8<S> {
#[inline(always)]
fn default() -> Self {
Self::new(unsafe { _mm256_setzero_si256() })
}
}
#[rustfmt::skip]
macro_rules! log_reduce_epu32_avx1 {
($value:expr; $op:ident) => {unsafe {
let ymm0 = $value;
... | true |
2854da7e0152866a9ea8467bf4f64e6caf63b2c4 | Rust | bcongdon/overcast-to-sqlite | /src/sqlite.rs | UTF-8 | 2,278 | 2.9375 | 3 | [
"MIT"
] | permissive | use rusqlite::{params, Connection};
use crate::overcast::Feed;
// Creates tables for podcast feeds and episodes, if they don't already exist.
pub fn create_tables(conn: &Connection) -> Result<(), Box<dyn std::error::Error>> {
conn.execute(
"CREATE TABLE IF NOT EXISTS feeds (
id INTEGER PRIMARY... | true |
2331f05493a6b89d253995bfd298e8e4e5ff039e | Rust | dylanmckay/compiler | /src/ir/read/tokenizer.rs | UTF-8 | 13,674 | 3.34375 | 3 | [
"MIT"
] | permissive | use super::{Token,Characters};
use util;
use std;
use std::error::Error;
pub type Result<T> = std::result::Result<T,String>;
/// A list of symbols to be tokenized.
///
/// They are sorted from most specific to least.
/// This means that `+=` will precede `+` etc.
pub const SYMBOL_LIST: &'static [&'static str] = &[
... | true |
157bdaa1c5b7578ab0b76328d91eacc1dbf270a3 | Rust | caibirdme/leetcode_rust | /src/prob_410.rs | UTF-8 | 1,867 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::cmp::{max,min};
impl Solution {
pub fn split_array(nums: Vec<i32>, m: i32) -> i32 {
if m == 1 {
return nums.iter().sum();
}
let nums_i64: Vec<i64> = nums.into_iter().map(|v| v as i64).collect();
let (mut l, mut r) = (0, std::i32::MAX as i64);
let mut ans... | true |
5ec07d5d5f4fabcedacb3aa1f2315d2b96f7c076 | Rust | irdiavxhi/nodejs-global-summit-2020-napi-rust | /examples-rust/example3-wasm/src/lib.rs | UTF-8 | 384 | 2.9375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use js_sys as js;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn sum_of_squares(array: js::Float64Array) -> f64 {
array.to_vec().iter().map(|&i| i * i).sum()
}
#[wasm_bindgen]
pub fn sum_of_squares2(array: js::Float64Array) -> f64 {
let mut result = 0.0;
for i in 0..array.length() {
let x = ... | true |
653f08d0c2b45d265eb7b4e33b03b7ee54ebd969 | Rust | snsvrno/updater-lp-rs | /src/sources/github/restson.rs | UTF-8 | 694 | 2.671875 | 3 | [] | no_license | use sources::github::{ asset::Asset, params::GithubParams };
#[derive(Serialize,Deserialize,Debug)]
pub struct GitRest {
pub url: String,
pub tag_name: String,
pub assets: Vec<Asset>
}
// for getting the latest one
impl<'a> restson::RestPath<&'a GithubParams> for GitRest {
fn get_path(repo: &'a Githu... | true |
b3471f6700a0ba8bb588aa4945f5a15dabff4fa2 | Rust | Giovan/lumen | /liblumen_alloc/src/erts/term/pid.rs | UTF-8 | 6,934 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use core::cmp;
use core::convert::{TryFrom, TryInto};
use core::default::Default;
use core::fmt::{self, Display};
use core::hash::{Hash, Hasher};
use core::ptr;
use liblumen_core::locks::RwLock;
use lazy_static::lazy_static;
use crate::borrow::CloneToProcess;
use crate::erts::exception::system::Alloc;
use crate::ert... | true |
bb5d47b4de62fab57d904502e879d6a604dc4fe7 | Rust | fabianschuiki/llhd | /src/ty.rs | UTF-8 | 7,821 | 3.484375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright (c) 2017-2021 Fabian Schuiki
//! Types of values.
use itertools::Itertools;
use std::sync::Arc;
pub use self::TypeKind::*;
/// An LLHD type.
pub type Type = Arc<TypeKind>;
/// The different kinds of types.
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TypeKind... | true |
5a7773394ca7a257f00347819728bc108b45fb06 | Rust | vigna/dsi-bitstream-rs | /src/traits/downcastable.rs | UTF-8 | 1,994 | 3.046875 | 3 | [
"Apache-2.0",
"LGPL-2.1-only"
] | permissive | /*
* SPDX-FileCopyrightText: 2023 Tommaso Fontana
* SPDX-FileCopyrightText: 2023 Inria
*
* SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
*/
/// `DowncastableInto : DowncastableFrom = Into : From`, It's easyer to use to
/// specify bounds on generic variables
pub trait DowncastableInto<W>: Sized {
/... | true |
d878ff263b18a8debada67c77f1698d6a9c4c2ac | Rust | nordsoyv/rust_win32 | /game-core/src/entities/wall.rs | UTF-8 | 1,248 | 3.1875 | 3 | [] | no_license | use entities::{BoundingBox, Collider, Color, Drawable, Position};
use math::vector::Vector2d;
pub struct Wall {
pos: Vector2d,
width: f32,
height: f32,
color: Color,
}
impl Wall {
pub fn new(pos: Vector2d, width: f32, height: f32,) -> Wall {
Wall {
pos,
width,
... | true |
ed65e7735ddf410fc2891a77829e2e350caa1cfb | Rust | hubris-lang/hubris | /src/hubris/elaborate/pattern_matching/mod.rs | UTF-8 | 7,528 | 2.515625 | 3 | [
"MIT"
] | permissive | use super::super::ast::{self};
use super::super::core::{self, Term};
use super::{LocalElabCx, Error};
use std::collections::HashMap;
struct PatternMatchCx<'ecx, 'cx: 'ecx> {
elab_cx: &'ecx mut LocalElabCx<'cx>,
}
mod renamer;
mod simplify;
use self::simplify::*;
impl<'ecx, 'cx: 'ecx>PatternMatchCx<'ecx, 'cx> {... | true |
fd2c77f8e3b1bce0a36d9e17b52916c20c4d5ec4 | Rust | nsoroush/Rust-tutorial | /Examples/Struct/RecursiveTypeInfiniteSize.rs | UTF-8 | 397 | 2.875 | 3 | [] | no_license | #[derive(Debug)]
struct Course {
name: String,
passed: bool,
teacher: Teacher
}
#[derive(Debug)]
struct Teacher {
name: String,
course: Course
}
fn main() {
let course: Course;
course = Course {
name: String::from("درس۱"),
passed: false,
teacher: Teacher {
... | true |
c670a978c5fed1589f31636c83da5f51ad42fb55 | Rust | a-ste/vxe | /vxe_renderer/src/types/mesh.rs | UTF-8 | 1,671 | 3.15625 | 3 | [
"MIT"
] | permissive | use crate::data::{Vertex, LumTess};
use crate::context::Context;
use crate::types::material::Material;
use crate::types::{Transform, DeferredFrameBuffer};
use std::rc::Rc;
use std::sync::RwLock;
/// Structure for containing renderable meshes with assigned materials
pub struct Mesh {
vertices: Vec<Vertex>,
indi... | true |
026218513753c6725c8be8566927a10c88ae2b8b | Rust | mb64/masm-rs | /src/x86_assembler.rs | UTF-8 | 102,555 | 2.703125 | 3 | [] | no_license | #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
#[repr(u8)]
pub enum Rounding {
ToNearestWithTiesToEven = 0,
TowardNegativeInfiniti = 1,
TowardInfiniti = 2,
TowardZero = 3,
}
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug, Hash)]
#[repr(u8)]
pub enum RegisterID {
EA... | true |
e1d57ab0cd8c67b54b4996eac87f402b417257f6 | Rust | Disasm/rpi-os-fs | /fat32/src/vfat/file.rs | UTF-8 | 3,501 | 2.765625 | 3 | [] | no_license | use std::cmp::min;
use std::io::{self, Write, SeekFrom};
use vfat::cluster_chain::ClusterChain;
use traits::File;
use vfat::VFatEntry;
use traits::FileOpenMode;
use vfat::lock_manager::LockMode;
use traits::BlockDevice;
pub struct VFatFile {
chain: ClusterChain,
size: u32,
old_size: u32,
entry: VFatEn... | true |
376e283296305b05cded075547d0980ae858cd53 | Rust | Ogi22po/rustypaste | /src/mime.rs | UTF-8 | 2,230 | 2.90625 | 3 | [
"MIT"
] | permissive | use actix_files::file_extension_to_mime;
use mime::{FromStrError, Mime};
use regex::Regex;
use std::path::PathBuf;
use std::str::FromStr;
/// Matcher for MIME types.
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct MimeMatcher {
/// MIME type to set for the matched file name.
p... | true |
70a2c3133bbe2a7feadeb01a152cc354231045ab | Rust | mvlabat/bevy_megaui | /src/input.rs | UTF-8 | 4,194 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::{MegaUiContext, MegaUiSettings, WindowSize};
use bevy::{
app::Events,
ecs::{Resources, World},
input::{keyboard::KeyCode, mouse::MouseButton, Input},
window::{CursorMoved, ReceivedCharacter, Windows},
};
// Is a thread local system because `megaui::Ui` (`MegaUiContext`) doesn't implement Sen... | true |
25e7f51349bff75be9ba88d8583feb776faed7e4 | Rust | dannyzed/gosol | /src/game/simpleboard.rs | UTF-8 | 11,262 | 3.0625 | 3 | [
"MIT"
] | permissive | use game::board::{GoBoard, GoMove, State};
#[derive(Clone, Debug)]
pub struct Group {
indicies: Vec<usize>,
pub liberties: i8,
owner: State,
}
// A very simple GoBoard implementation where little attempt is made to optimize space and
// time complexities.
#[derive(Clone)]
pub struct SimpleBoard {
pub ... | true |
42692bc576f7a70deb629515e23c6af82f88ab4b | Rust | Daniel-Aaron-Bloom/Simple-Transaction-Manager | /src/transaction_set.rs | UTF-8 | 3,598 | 3.1875 | 3 | [] | no_license | use cached::Cached;
use std::collections::HashMap;
use crate::transaction::DisputableTransaction;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum State {
Committed,
Resolved,
Disputed,
ChargedBack,
ChargedBackFinal,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum UpdateFailure {
... | true |
0dbfbf1fd67ad9f7d91b9b9f346fb744132221ba | Rust | forbjok/rust-codesign | /cli/src/main.rs | UTF-8 | 4,076 | 2.71875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::path::PathBuf;
use log::{debug, LevelFilter};
use structopt::StructOpt;
use codesign::{CodeSignError, SignParams, SignTool};
#[derive(Debug, StructOpt)]
#[structopt(name = "CodeSign", version = env!("CARGO_PKG_VERSION"), author = env!("CARGO_PKG_AUTHORS"))]
struct Opt {
#[structopt(short = "v", parse(fr... | true |
3601cf68e006d820096041d236a3ae21b9d7bf5b | Rust | tiziano88/scroll-phat-hd-rs | /src/lib.rs | UTF-8 | 308 | 2.515625 | 3 | [
"MIT"
] | permissive | //! # Scroll pHAT HD
//!
//! Sample usage:
//!
//! ```
//! let mut display = scroll_phat_hd::display::TermDisplay::new();
//! let mut scroller = scroll_phat_hd::scroller::Scroller::new(&mut display);
//! scroller.set_text("ABC");
//! scroller.show();
//! ```
mod shared;
pub mod display;
pub mod scroller;
| true |
a82bac28b086006c8e9d52e4cd3ca1a1e11f80b4 | Rust | Kilerd/typhoon | /ast/src/complex_struct.rs | UTF-8 | 1,759 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::{Expr, FunctionDeclare, Identifier, Type};
use std::collections::BTreeMap;
use std::sync::Arc;
#[derive(Debug)]
pub enum ModuleItem {
FunctionDeclare(FunctionDeclare),
StructDeclare(StructDeclare),
}
//
// impl ModuleItem {
// pub fn codegen(self, upper_context: Arc<TyphoonContext>) {
// ... | true |
01b139e1fdb54c115009fc64b272b3a754d9ce38 | Rust | HadrienG2/bacara | /src/hole.rs | UTF-8 | 35,701 | 3.390625 | 3 | [] | no_license | //! Mechanism for searching holes in the allocation bitmap
use crate::{SuperblockBitmap, BLOCKS_PER_SUPERBLOCK};
/// Location of a free memory "hole" within the allocation bitmap
///
/// The hole can be bigger than requested, so the memory allocation code is
/// encouraged to try moving its hole forward when allocati... | true |
16c78012ac4184615eca403c7b19744ba323cda7 | Rust | JakubOnderka/treebitmap | /src/tree_bitmap/allocator.rs | UTF-8 | 16,783 | 2.796875 | 3 | [
"MIT"
] | permissive | // Copyright 2016 Hroi Sigurdsson
//
// Licensed under the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
#[cfg(feature = "alloc")]
use alloc::vec::Vec;
use std::cmp;
use std::fmt;
use std::mem;
use std::ptr;
us... | true |
78f0a5ee4d06c1ebdcbabcce88ac00a990c0aa42 | Rust | jgke/purkka | /src/purkkaconverter/src/imports.rs | UTF-8 | 2,761 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use crate::traits::TreeTransformer;
use crate::PurkkaToC;
use purkkasyntax::visitor::*;
/// Strip imports
use purkkasyntax::*;
#[derive(Debug)]
pub struct StripImports<'a> {
context: &'a mut PurkkaToC,
}
#[allow(unused_must_use)]
impl<'a> TreeTransformer<'a> for StripImports<'a> {
fn new(context: &'a mut Purk... | true |
8f14ffc0bb6853f8acc5091aed77a4d4769ef6a4 | Rust | wendersonferreira/fibonacci-rust | /src/main.rs | UTF-8 | 282 | 3.3125 | 3 | [] | no_license | fn main() {
for n in 0..301 {
println!("The fibonacci number at {} position is {}", n, fibonacci(n));
}
}
fn fibonacci(n: u32) -> u32 {
fn internal(n: u32, a:u32, b:u32) -> u32 {
match n {
0 => a,
_ => internal(n-1, b, (a+b)%10000)
}
}
internal(n%1500000,0,1)
}
| true |
b8b2fe1c3d099b06284e14ad32e6b45f4410572d | Rust | alexxbb/sprios | /src/renderer/src/utils.rs | UTF-8 | 452 | 3.1875 | 3 | [] | no_license | // f32::clamp is unstable,
pub trait Clip {
type Output;
fn clip(self, min: Self::Output, max: Self::Output) -> Self::Output;
}
impl Clip for f32 {
type Output = f32;
#[inline]
fn clip(self, min: Self::Output, max: Self::Output) -> Self::Output {
debug_assert!(min <= max);
let mut ... | true |
9cb2f1f39912f1f3869dc2df32d359ec78722383 | Rust | ikubetoomuzik/advent_of_code | /2022/src/lib.rs | UTF-8 | 525 | 2.921875 | 3 | [] | no_license | pub fn bubble_sort(items: &mut [u32]) {
let max_index: usize = items.len() - 1;
let mut num_changes = 0;
loop {
let mut idx = 0;
while idx < max_index {
if items[idx] < items[idx + 1] {
let temp = items[idx];
items[idx] = items[idx + 1];
... | true |
8ffe979916b346d4eda6d9963bfd05e5c60e92a7 | Rust | Lawliet-Chan/phala-pruntime | /vendor/webpki/sgx/webpki-sgx-test/enclave/src/calendar.rs | UTF-8 | 1,770 | 2.78125 | 3 | [
"LicenseRef-scancode-mit-taylor-variant",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //#[test]
pub fn test_days_before_unix_epoch() {
use webpki::calendar::{days_before_year_ad, DAYS_BEFORE_UNIX_EPOCH_AD};
assert_eq!(DAYS_BEFORE_UNIX_EPOCH_AD, days_before_year_ad(1970));
}
//#[test]
pub fn test_days_in_month() {
use webpki::calendar::days_in_month;
assert_eq!(days_in_month(2017, 1), 31... | true |
1379e2d7c61c66310992ab04d5010eb80dd33f61 | Rust | fiji-flo/dino-park-packs | /src/cis/operations.rs | UTF-8 | 4,043 | 2.5625 | 3 | [
"MIT"
] | permissive | use chrono::DateTime;
use chrono::Utc;
use cis_client::AsyncCisClientTrait;
use cis_profile::crypto::SecretStore;
use cis_profile::crypto::Signer;
use cis_profile::schema::AccessInformationProviderSubObject;
use cis_profile::schema::Display;
use cis_profile::schema::KeyValue;
use cis_profile::schema::Profile;
use cis_p... | true |
77e754d65ed8d22d81846a20dd93fa4445d61730 | Rust | avmi/timely-dataflow | /timely/src/dataflow/channels/pact.rs | UTF-8 | 7,381 | 2.859375 | 3 | [
"MIT"
] | permissive | //! Parallelization contracts, describing requirements for data movement along dataflow edges.
//!
//! Pacts describe how data should be exchanged between workers, and implement a method which
//! creates a pair of `Push` and `Pull` implementors from an `A: AsWorker`. These two endpoints
//! respectively distribute and... | true |
c96ce4d67b0246090cb02bb85f59a0d265ef0a69 | Rust | the-kenny/hellschreiber | /src/tests/db.rs | UTF-8 | 12,985 | 3.046875 | 3 | [] | no_license | use ::*;
fn db() -> Db {
Db::new().unwrap()
}
fn validate_datoms(datoms: &[Datom]) {
use std::collections::{BTreeMap,BTreeSet};
// TODO: This logic is duplicated in `Db::entity`
let mut values: BTreeMap<(EntityId, Attribute), BTreeSet<&Value>> = BTreeMap::new();
for d in datoms {
let mut e... | true |
83eff7c2defca5194e405a8b870c685d25ef5328 | Rust | isgasho/intellij-theme | /src/palette.rs | UTF-8 | 4,888 | 2.90625 | 3 | [] | no_license | use std::ops::Range;
use tincture::{Hue, Oklch};
pub(crate) enum Palette {
Normal,
GreyscaleBase,
}
impl Palette {
pub(crate) fn base(&self, scale: BaseScale) -> Oklch {
let chroma = match self {
Self::Normal => scale.chroma(),
Self::GreyscaleBase => 0.0,
};
... | true |
bd127f5590f81189e9e6926504049e4dae5aeb26 | Rust | winksaville/fuchsia | /garnet/bin/odu/src/generator.rs | UTF-8 | 15,043 | 2.90625 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Implementation of Generator thread and Generator trait.
//!
//! Generator thread accept a set of serializable arguments.
use {
crate::common_operat... | true |
13336d6cd675c0c0906c96328c889c6d88cef77f | Rust | lenscas/mergui | /src/core/image_button.rs | UTF-8 | 2,341 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use crate::{
channels::clickable::{BasicClickable as Clickable, ClickSetter as Channel},
widgets::{Widget, WidgetConfig},
};
use quicksilver::{
geom::{Rectangle, Vector},
graphics::Color,
graphics::Graphics,
graphics::Image,
Result, Window,
};
//use quicksilver::prelude::{Blended, Color, Im... | true |
976c808c0feb7fbf9322671e06c12d047bd7bd69 | Rust | stoically/rune | /crates/runestick/src/tuple.rs | UTF-8 | 1,190 | 3.21875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::Value;
use std::fmt;
use std::ops;
/// Struct representing an anonymous tuple.
#[derive(Clone)]
#[repr(transparent)]
pub struct Tuple {
inner: Box<[Value]>,
}
impl Tuple {
/// Convert into inner.
pub fn into_inner(self) -> Box<[Value]> {
self.inner
}
}
impl fmt::Debug for Tuple {
... | true |
26cf0bee9143e50396a0f797832e04e795664c9b | Rust | LukeStorry/advent-of-code-2020 | /rust/src/day6.rs | UTF-8 | 1,833 | 3.453125 | 3 | [] | no_license | use std::fs::read_to_string;
use std::collections::HashSet;
pub fn solve() {
let answers = read_to_string("../inputs/6.txt").unwrap();
print!("Day 6 part 1: {}\n", part_1(&answers));
print!("Day 6 part 2: {}\n", part_2(&answers));
}
fn part_1(answers: &str) -> usize {
answers.split("\n\n")
.m... | true |
cda070ee2a9956cf18fad27f3c7e55884e235b2b | Rust | wlindley/advent2018 | /third/two/src/main.rs | UTF-8 | 2,322 | 3.203125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn main() {
let rects = get_rects();
let mut locations: HashMap<Point, u32> = HashMap::new();
for rect in &rects {
for point in rect.points() {
*locations.entry(point).or_insert(0) += 1;
... | true |
8d1b634974f7a3b565cb1e96ead3eadadca409bf | Rust | Klauswk/rust-chip | /src/keyboard.rs | UTF-8 | 1,586 | 3.453125 | 3 | [
"MIT"
] | permissive | use sdl2::keyboard::Keycode;
pub struct Keyboard {
pub keys_pressed: Vec<u8>,
pub last_key_pressed: u8,
}
impl Keyboard {
pub fn new() -> Keyboard {
return Keyboard {
keys_pressed: Vec::new(),
last_key_pressed: 0,
};
}
pub fn is_key_pressed(&mut self, keyco... | true |
13905313162e05f2e454becba9d8cfc858032f7b | Rust | ackintosh/sandbox | /rust/leetcode/src/kids_with_the_greatest_number_of_candies.rs | UTF-8 | 1,005 | 3.28125 | 3 | [] | no_license | // https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/
struct Solution;
impl Solution {
pub fn kids_with_candies(candies: Vec<i32>, extra_candies: i32) -> Vec<bool> {
let greatest = {
let mut c = candies.clone();
// プリミティブのソートには sort ではなく sort_unstable を使う
... | true |
0ae3d4a13c340f6c1acbf3af1e344fed7057e6fd | Rust | stillinbeta/puccinia | /src/lib.rs | UTF-8 | 6,847 | 2.984375 | 3 | [] | no_license | use cursive::traits::Identifiable;
use cursive::Cursive;
use rand::rngs::SmallRng;
use rand::FromEntropy;
use rand::Rng;
use std::convert::TryFrom;
pub mod view;
#[derive(Debug, Copy, Clone, PartialEq)]
enum Cell {
Alive,
Dead,
}
impl Default for Cell {
fn default() -> Cell {
Cell::Dead
}
}
... | true |
3ba1fc91b36de2bd6844af24657ab9e30d23d4d4 | Rust | caente/coursera_graphs | /src/week2.rs | UTF-8 | 3,758 | 3.21875 | 3 | [] | no_license | use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
#[derive(Debug, Clone, Eq, Copy, Hash)]
pub struct Edge {
start: usize,
end: usize,
cos... | true |
fef2e072e2dc3b0734800effdb9b72f8f7b5ee48 | Rust | swgillespie/jit.rs | /tests/lib.rs | UTF-8 | 5,065 | 2.640625 | 3 | [
"MIT"
] | permissive | #![feature(plugin)]
#![allow(unstable)]
#[no_link] #[plugin] #[macro_use]
extern crate jit_macros;
extern crate jit;
extern crate test;
use jit::*;
use jit::typecs::*;
use std::default::Default;
use std::num::Float;
use test::Bencher;
macro_rules! test_compile(
($ty:ty, $test_name:ident, $kind:expr) => (
#[... | true |
984e258cb7d5e43636ab9b25091b06086e0be171 | Rust | RyanWarnock/taskers | /src/tasklist.rs | UTF-8 | 4,565 | 3.203125 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::io;
use std::fs::OpenOptions;
use std::fs::DirBuilder;
use std::env;
use csv;
use task::Task;
pub struct TaskList {
pub task_list: Vec<Task>,
pub task_list_location: String,
}
impl TaskList {
pub fn new() -> TaskList {
let task_list: Vec<Task> = Vec::new();
... | true |
f35f87883c3b92c6feb0eddfbe545bf42b61cffe | Rust | crestonbunch/reticulated | /lexer/src/tokens.rs | UTF-8 | 11,136 | 3.578125 | 4 | [
"MIT"
] | permissive | use std::fmt;
/// String literals can be preceeded by any of b, r, u, f, rb, rf in Python
/// so this enum tracks which flag (if any) is present on the string.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum StringFlag {
B,
R,
U,
F,
Rb,
Rf,
}
impl fmt::Display for StringFlag {
... | true |
f6308d23524e921389ca86c4e1e3010bd31156f5 | Rust | newAM/r3 | /src/r3/src/utils/prio_bitmap.rs | UTF-8 | 10,034 | 3.203125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Provides `FixedPrioBitmap`, a bit array structure supporting
//! logarithmic-time bit scan operations.
use core::{convert::TryFrom, fmt};
use super::{ctz::trailing_zeros, BinInteger, Init};
/// The maximum bit count supported by [`FixedPrioBitmap`].
pub const FIXED_PRIO_BITMAP_MAX_LEN: usize = WORD_LEN * WORD_LEN... | true |
3277db7ff97c03d8d0bbd2f5a972dc14fe3dc812 | Rust | linianhui/div | /tests/class_test/constant_long_test.rs | UTF-8 | 446 | 2.78125 | 3 | [
"MIT"
] | permissive | extern crate div;
use div::class::ConstantLong;
use div::class::ConstantTag;
use div::class::U8Reader;
#[test]
fn test_constant_long() {
let mut u8_reader = U8Reader::new(&[0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0]);
let constant_long = ConstantLong::new(&mut u8_reader);
assert_eq!(ConstantTag::Long,... | true |
88d7e166afd9fbc75e4fb64510d7d353bb0caf03 | Rust | cmisenas/aoc2019 | /src/day5.rs | UTF-8 | 5,414 | 3.140625 | 3 | [] | no_license | use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
pub fn main() {
let lines = read_lines_as_str("./day5.input");
let program = lines[0]
.split(",")
.map(|l| l.parse::<i32>().unwrap())
.collect::<Vec<i32>>();
let answer1 = solve1(program.clone());
let answer2 ... | true |
ca26b10f8f004fc4dd2c2dc1c22efa50bdef6fc4 | Rust | PatrykStronski/KnapsackProblem | /src/task1.rs | UTF-8 | 3,261 | 3.390625 | 3 | [] | no_license | use rand::Rng;
use csv::Writer;
use std::error::Error;
struct Obj {
weight: u32,
price: u32,
size: u32
}
fn save_to_file(arr: &mut[Obj],n:u32,w:u32,s:u32, out_file: String) -> Result<(), Box<dyn Error>> {
let mut wtr = Writer::from_path(out_file)?;
wtr.write_record(&[n.to_string(),w.to_string(),s.... | true |
179beff6fe02a58240512034a8144a8e78552d67 | Rust | AustinHaugerud/oxidsys | /src/language/operations/multiplayer/player_get_agent_id.rs | UTF-8 | 805 | 2.546875 | 3 | [
"MIT"
] | permissive | use language::operations::{make_param_doc, Operation, ParamInfo};
pub struct PlayerGetAgentIdOp;
const DOC: &str =
"Retrieves player's current agent reference. Returns a negative value if player has no agent.";
pub const OP_CODE: u32 = 406;
pub const IDENT: &str = "player_get_agent_id";
impl Operation for Play... | true |
5d0244a36b97ca1299dce5d8e075f5e32bde8267 | Rust | bumblepie/advent-of-code-2018 | /day-4/part-1/src/lib.rs | UTF-8 | 5,636 | 2.90625 | 3 | [] | no_license | use lazy_static::*;
use chrono::prelude::*;
use regex::Regex;
use std::cmp::Ordering;
use chrono::Duration;
use std::collections::HashMap;
pub fn get_event_from_line(line: &str) -> Result<ShiftEvent, Box<std::error::Error>> {
lazy_static! {
static ref event_regex: Regex =
Regex::new(r"\[(\d{4... | true |
2fb97b822b725be518af98390c4493544b525e32 | Rust | Ogeon/palette | /palette/src/cast/as_components_traits.rs | UTF-8 | 14,930 | 2.96875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::fmt::Debug;
use super::{
into_component_slice, into_component_slice_mut, try_from_component_slice,
try_from_component_slice_mut, ArrayCast, SliceCastError,
};
/// Trait for casting a reference to a collection of colors into a reference to
/// a collection of color components without copying.
///
///... | true |
0e9c3129030de697458aef02bc7323c029bcafa7 | Rust | nymtech/nym | /sdk/rust/nym-sdk/src/mixnet/native_client.rs | UTF-8 | 7,722 | 2.671875 | 3 | [
"CC0-1.0",
"Apache-2.0"
] | permissive | use crate::mixnet::client::MixnetClientBuilder;
use crate::mixnet::traits::MixnetMessageSender;
use crate::{Error, Result};
use async_trait::async_trait;
use futures::{ready, Stream, StreamExt};
use log::error;
use nym_client_core::client::{
base_client::{ClientInput, ClientOutput, ClientState},
inbound_message... | true |
0cbb2f5293f474dd836fb8e8f584c728d10789ca | Rust | Noah-Kennedy/odrive-rs | /examples/hoverboard_calibration.rs | UTF-8 | 1,312 | 2.671875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::env::args;
use std::io::Write;
use std::path::Path;
use serialport::SerialPortSettings;
use odrive_rs::commands::ODrive;
use odrive_rs::enumerations::{AxisID, AxisState};
fn main() {
// Get CLI args
let args: Vec<String> = args().collect();
// Create serial port settings
let mut settings = ... | true |
9b779ca1c0164e228f1c9444ac621e8f6763200e | Rust | sujayakar/demikernel | /src/rust/catnip/src/async/schedule.rs | UTF-8 | 2,103 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
use super::coroutine::{Coroutine, CoroutineId, CoroutineStatus};
use std::{cmp::Ordering, collections::BinaryHeap, time::Instant};
#[derive(PartialEq, Eq)]
struct Record {
when: Instant,
cid: CoroutineId,
}
impl Ord for Record {
f... | true |
e788b7495ab547ed160b3e6cbc308d0e8dc0f923 | Rust | camjackson/open-spaceial-distancing | /src/main.rs | UTF-8 | 1,270 | 2.6875 | 3 | [] | no_license | mod direction;
mod navigation;
mod office;
mod show_path;
mod stats;
use navigation::WallHuggingNavigator;
use stats::{stats_for_p, SimulationParams, Stats};
fn main() {
let params = SimulationParams {
sample_count: 10_000,
office_width: 10,
office_height: 10,
print_path: false,
... | true |
f81dfe8e7426715d07779f920e86fb8689f06eef | Rust | aoyagikouhei/rust-tw | /src/oauth.rs | UTF-8 | 2,617 | 2.859375 | 3 | [] | no_license | extern crate url;
use crypto::sha1::Sha1;
use crypto::hmac::Hmac;
use rand::{Rng, thread_rng};
use rustc_serialize::base64;
use crypto::mac::{Mac, MacResult};
use rustc_serialize::base64::ToBase64;
use time::now_utc;
pub fn encode(s: &str) -> String {
url::form_urlencoded::byte_serialize(s.as_bytes()).collect::<S... | true |
833ee1eb3940656522802a2e46c7b4f7541d8608 | Rust | linclelinkpart5/voxane | /src/sample.rs | UTF-8 | 4,393 | 3.140625 | 3 | [] | no_license | use std::sync::Arc;
use std::sync::Mutex;
use std::sync::MutexGuard;
use std::collections::VecDeque;
use crate::Error;
use crate::types::SignalStrength;
pub type Sample = f32;
#[derive(Clone)]
pub struct SampleBuffer(Arc<Mutex<VecDeque<(Sample, Sample)>>>);
impl SampleBuffer {
/// Create a new sample buffer.
... | true |
a13d91b1e7da120e44b59878cf668f59d23890bd | Rust | 47ng/strava_api.rs | /src/api.rs | UTF-8 | 2,142 | 2.953125 | 3 | [] | no_license | use crate::auth::AccessToken;
use reqwest;
#[derive(Debug)]
pub struct Pagination {
/// An epoch timestamp to use for filtering results
/// that have taken place before a certain time.
/// (when using time-based cursors)
pub before: u64,
/// An epoch timestamp to use for filtering results
/// that have ta... | true |
8f3467b8d3c52b06f147bd9667a0c2c90519f6ee | Rust | jo1gi/podcast-dl | /src/feed/strategy/execute.rs | UTF-8 | 2,542 | 2.78125 | 3 | [] | no_license | use crate::{
error::{Error, ParseError},
Podcast,
feed::{
strategy::{Strategy, Operation, PodcastOperation, UrlOperation},
parse::parse_rss_feed,
},
};
use url::Url;
pub async fn execute_strategy(strategy: &Strategy) -> Result<Podcast, Error> {
let mut url = strategy.url.clone();
... | true |
463b62b83385b61d69c2d2d2f04cbd2b44cf6ebe | Rust | ZacharyKamerling/rust_rts | /src/data/target_type.rs | UTF-8 | 741 | 3.203125 | 3 | [
"MIT"
] | permissive | #[derive(Clone, Copy, Debug)]
pub struct TargetType {
byte: u8,
}
pub enum TargetTypes {
Ground,
Air,
Water,
Underwater,
Hover,
}
impl TargetType {
pub fn new() -> TargetType {
TargetType { byte: 0 }
}
pub fn new_all_set() -> TargetType {
TargetType { byte: 0b11111... | true |
4465ddfb4d3710ba3a907919f1a0fe2d05ca0727 | Rust | Byron/gitoxide | /gix-filter/tests/worktree/mod.rs | UTF-8 | 3,323 | 2.96875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod encoding {
mod for_label {
use gix_filter::worktree;
#[test]
fn unknown() {
assert_eq!(
worktree::encoding::for_label("FOO").unwrap_err().to_string(),
"An encoding named 'FOO' is not known"
);
}
#[test]
fn ... | true |
9c664395cc847bd6f1886a834abadfcfa56f0586 | Rust | archshift/anymsg | /src/test.rs | UTF-8 | 1,776 | 2.515625 | 3 | [] | no_license | use *;
use std::thread;
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering};
#[test]
pub fn test_multi() {
let mut pump = Pump::new();
struct Client1(usize);
struct Client2(usize);
struct MsgIncr;
struct MsgVerify;
static COUNTER: AtomicUsize = AtomicUsize::new(0);
static RAN_VERIF... | true |
02a2b8bba085d08c970e7a245af9bdf3c2b7b9e8 | Rust | juschei/rust-chess | /src/evaluation.rs | UTF-8 | 9,559 | 2.578125 | 3 | [] | no_license | /////////////////////////////////////////////////////////////////////
//internal modules:
use crate::structs::*;
use crate::statics::*;
use crate::validation::*;
//external modules:
use rayon::prelude::*;
/////////////////////////////////////////////////////////////////////
pub fn eval(board: &BoardStructure) -> i... | true |
f95aa21c670649669b014d205a2d123c3cbbc8b1 | Rust | alextanhongpin/rust-web | /src/main.rs | UTF-8 | 705 | 2.671875 | 3 | [] | no_license | extern crate iron;
extern crate router;
use iron::prelude::*;
use iron::status;
use router::Router;
fn main() {
let mut router = Router::new();
router.get("/", hello_world, "index");
router.get("/greet/:name", greet, "greet");
fn hello_world(_: &mut Request) -> IronResult<Response> {
Ok(Res... | true |
bf84ebd17549648979ff1d022dc31524e7884cf0 | Rust | berkowski/mio-serial | /examples/read_serialport.rs | UTF-8 | 2,676 | 3.125 | 3 | [
"MIT",
"MPL-2.0"
] | permissive | //! Simple example that echoes received serial traffic to stdout
extern crate mio;
extern crate mio_serial;
use mio::{Events, Interest, Poll, Token};
use std::env;
use std::io;
use std::io::Read;
use std::str;
use mio_serial::SerialPortBuilderExt;
const SERIAL_TOKEN: Token = Token(0);
#[cfg(unix)]
const DEFAULT_TT... | true |
66da22a38d21d706f4573691c66ec656c0d472bf | Rust | kanchan20xx/first_rust | /first/src/main.rs | UTF-8 | 647 | 3.59375 | 4 | [] | no_license | // coding at utf-8
fn main() {
// Display Hello, world!
println!("Hello, world!");
println!("You should input number!");
// let : immutable 変数を作る.
// mut : mutable変数に昇格
// String型の変数作成。new()はstatic関数。(と思う。)
let mut input = String::new();
// 標準入力から、一行分読み取り -> inputに格納。
// & は参照
//... | true |
c017b79e9456ada0b92c9ee4ad0526aa10dec356 | Rust | curliph/riscv-emu | /src/peripherals/fe310_g002/fe310_uart.rs | UTF-8 | 4,182 | 2.953125 | 3 | [
"MIT"
] | permissive | // FE310 UART Device
// https://static.dev.sifive.com/FE310-G000.pdf
use crate::console::Console;
const UART_TXEN: u32 = 0x1;
const UART_RXEN: u32 = 0x1;
const UART_TXWM: u32 = 0x1;
const UART_RXWM: u32 = 0x2;
pub struct Fe310Uart {
// /Transmit data register
txdata: u32,
/// Receive data register (RO)
... | true |
9462b193e71cb1fdfc6355a7712851e06c9ee9d4 | Rust | CyberFlameGO/abi_stable_crates | /abi_stable/src/std_types/tuple.rs | UTF-8 | 3,398 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | /*!
Contains ffi-safe equivalents of tuples up to 4 elements.
*/
#![allow(non_snake_case)]
macro_rules! declare_tuple {
(
struct_attrs[ $(#[$meta:meta])* ]
into_tuple_attrs[ $(#[$into_tuple_attrs:meta])* ]
$tconstr:ident[$( $tparam:ident ),* $(,)? ]
) => (
$(#[$meta])*
#[derive(Debug, Copy, ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.