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
b977c217f749729588a6f005b8a2ce090fac26b2
Rust
tezlm/tui-input
/src/backend/termion.rs
UTF-8
2,110
3.140625
3
[ "MIT" ]
permissive
use crate::input::InputRequest; use std::io::{Result, Write}; use termion::cursor::Goto; use termion::event::{Event, Key}; use termion::style::Invert; use termion::style::NoInvert; /// Converts termion event into input requests. pub fn to_input_request(evt: &Event) -> Option<InputRequest> { use InputRequest::*; ...
true
e85a768ef0ba42b23387e5c13c17cc7c499697ee
Rust
dorucioclea/MaaraaDAO
/0xx_core_mix/src/bulletinboard/basic.rs
UTF-8
2,977
3.171875
3
[ "MIT", "CC0-1.0" ]
permissive
use std::collections::HashMap; use std::path::Path; use crate::bulletinboard::BBError; use crate::crypto::hashing; use crate::crypto::hashing::Hash; use crate::data::bytes::*; use crate::util; pub trait BasicBoard { fn list(&self) -> Result<Vec<String>, BBError>; fn get<A: ToByteTree + Deser>(&self, target: S...
true
c284a78fc7b51070618a45048a71aedeb677120c
Rust
EdginAround/edgin_around_rendering
/edgin_around_rendering/src/expositors/preview.rs
UTF-8
3,352
2.609375
3
[]
no_license
use crate::{ animations, game, renderers, utils::{errors as err, geometry, graphics}, }; pub struct PreviewExpositor { sprites: game::Sprites, size: (usize, usize), renderer: renderers::FixedRenderer, program: gl::types::GLuint, loc_view: gl::types::GLint, loc_model: gl::types::GLint, ...
true
2c9543195ca3b1843ac7aa99bd6aa2789c92fe76
Rust
declanvk/dancing-links
/src/lib.rs
UTF-8
1,533
2.8125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![deny(missing_docs)] //! Implementation of [Dancing Links](https://en.wikipedia.org/wiki/Dancing_Links) //! and [Algorithm X](https://en.wikipedia.org/wiki/Knuth%27s_Algorithm_X) for solving //! [exact cover](https://en.wikipedia.org/wiki/Exact_cover) problems. pub mod grid; pub mod latin_square; pub mod queens; p...
true
985f6c7eb01a070b0c6f51133da361de69fbd23f
Rust
SierraSoftworks/rex-rs
/src/models/role_assignment.rs
UTF-8
2,492
2.875
3
[ "MIT" ]
permissive
use actix::prelude::*; use crate::api::APIError; #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub enum Role { Owner, Contributor, Viewer, Invalid, } impl Default for Role { fn default() -> Self { Role::Viewer } } impl From<&str> for Role { fn from(s: &str) ...
true
7bdf6aa8ecd85bc70710f1db52a5875b0c6cd347
Rust
sim82/rust_playground
/src/render_bits/math.rs
UTF-8
1,756
2.890625
3
[ "MIT", "Apache-2.0" ]
permissive
use cgmath::prelude::*; use cgmath::{Matrix4, Rad, Vector3}; pub fn perspective_projection(fov: Rad<f32>, a: f32, zn: f32, zf: f32) -> Matrix4<f32> { let f = Rad::cot(fov / 2f32); Matrix4::new( f / a, 0f32, 0f32, 0f32, 0f32, -f, 0f32, 0f32, ...
true
4c6db71096c012e949f9a82d444b2a8e76df84a2
Rust
bbqsrc/sentry-rust-1
/sentry-log/src/lib.rs
UTF-8
1,422
2.96875
3
[ "Apache-2.0" ]
permissive
//! Adds support for automatic Breadcrumb and Event capturing from logs. //! //! The `log` crate is supported in two ways. First, logs can be captured as //! breadcrumbs for later. Secondly, error logs can be captured as events to //! Sentry. By default anything above `Info` is recorded as breadcrumb and //! anything a...
true
45abecf57e1afa1f9debb371e5b1027fe5165670
Rust
Hakuyume/socketcan-rs
/src/socket/tests.rs
UTF-8
6,269
2.703125
3
[ "BSD-3-Clause" ]
permissive
use super::Socket; use crate::{sys, Cmsg, DataFrame, FdDataFrame, Frame, Id, Timestamping}; use rand::Rng; use spin::RwLock; use std::env; use std::ffi::CString; use std::io::ErrorKind; use std::io::Result; use std::os::unix::ffi::OsStrExt; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::thr...
true
52e1cd29bdf8a46da660a48f34a0d5a805b1e141
Rust
balena-os/os-config
/src/schema.rs
UTF-8
4,196
3
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::path::Path; use serde_json::Value; use crate::fs::read_file; use anyhow::{bail, Context, Result}; pub const SCHEMA_VERSION: &str = "1.0.0"; #[derive(Debug, Serialize, Deserialize, PartialEq)] pub struct OsConfigSchema { pub services: Vec<Service>, pub keys: Vec<String...
true
79b95ea4879b12a0543f06af6f391706c475ab33
Rust
hpatjens/instrument
/src/platform.rs
UTF-8
1,700
2.765625
3
[]
no_license
use std::mem; #[derive(Debug)] pub struct RecordingTimestamp(i64); impl RecordingTimestamp { // // new // #[cfg(target_os = "windows")] #[inline] pub fn now() -> Self { // https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps // https://d...
true
18952d9aa7ddae2fc7a58c1e1da7c7d87d4749c6
Rust
bikeshedder/validator
/validator_derive/tests/compile-fail/range/wrong_type.rs
UTF-8
259
2.921875
3
[ "MIT" ]
permissive
use validator::Validate; #[derive(Validate)] //~^ ERROR: proc-macro derive panicked //~^^ HELP: Validator `range` can only be used on number types but found `String` struct Test { #[validate(range(min = 10.0, max = 12.0))] s: String, } fn main() {}
true
a0919b67e4c037ac312a8a469c16c5af18481151
Rust
xaep/mh-zx-driver
/src/lib.rs
UTF-8
14,534
2.796875
3
[ "Apache-2.0" ]
permissive
/* Copyright 2020 Constantine Verutin 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 agreed to in writing, so...
true
d91c6d6dd0a42f548d138862ae2e0600df49dc97
Rust
RustAudio/cpal
/asio-sys/src/bindings/errors.rs
UTF-8
4,309
2.8125
3
[ "Apache-2.0" ]
permissive
use std::error::Error; use std::fmt; /// Errors that might occur during `Asio::load_driver`. #[derive(Debug)] pub enum LoadDriverError { LoadDriverFailed, DriverAlreadyExists, InitializationFailed(AsioError), } /// General errors returned by ASIO. #[derive(Debug)] pub enum AsioError { NoDrivers, H...
true
daf354ba9a8d57d1f676dd60fa67a1c0055f756e
Rust
rogithub/infonavit-api
/src/main.rs
UTF-8
1,538
2.515625
3
[]
no_license
#![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; use infonavit_api::info::CreditInfo; use infonavit_api::types::{Credit, Payment}; use rocket::http::Method; use rocket_contrib::json::Json; use rocket_cors::{AllowedHeaders, AllowedOrigins}; use std::error::Error; #[get("/credit/<id>")] fn ...
true
6a582d28fca0240478b5ed0b628f8a65e7212490
Rust
mihajlo-jovanovic/advent-of-code
/2020/rust/src/day18.rs
UTF-8
2,067
3.34375
3
[]
no_license
#[aoc_generator(day18)] fn parse_input(input: &str) -> Vec<String> { input.lines().map(|l| l.to_string()).collect() } #[aoc(day18, part1)] fn part1(input: &[String]) -> u64 { input.iter().map(|ex| eval(ex)).sum() } fn eval(ex: &str) -> u64 { eval_helper(&resolve_pars(ex)) } fn eval_helper(ex: &str) -> u6...
true
041f4d0578de1be96d8f31929da3c53f3d17cd16
Rust
rafaelcaricio/gremlin-rs
/gremlin-client/src/structure/value.rs
UTF-8
3,363
2.625
3
[ "Apache-2.0" ]
permissive
use crate::conversion::{BorrowFromGValue, FromGValue}; use crate::structure::{Edge, Path, Property, Vertex, VertexProperty}; use crate::GremlinResult; use chrono; use std::collections::{HashMap, VecDeque}; pub type Map = HashMap<String, GValue>; pub type List = Vec<GValue>; pub type Set = Vec<GValue>; pub type Date = ...
true
8ec32bc6e81529eb9f46efbdf58d89aae05bf7cd
Rust
tjdetwiler/frappe
/classfile/src/classfile.rs
UTF-8
4,752
2.875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::fmt; use std::vec::Vec; use super::{Attributes, ConstantPool, FieldInfo, MethodInfo}; #[derive(Debug)] pub struct ClassFile { /// Java classfile magic number. `0xcafebabe` is the only valid value for /// this field. pub magic: u32, /// The minor version of this classfile. pub minor_versio...
true
03f5062edab7c9ebe29cbcc9039d59d3e5070d20
Rust
derekdreery/yatzy
/src/main.rs
UTF-8
5,561
2.609375
3
[]
no_license
use anyhow::Error; use crossbeam_channel as channel; use druid::widget::{Align, Button, Flex, Label, TextBox}; use druid::{ lens::Field, AppDelegate, AppLauncher, BoxConstraints, Color, Command, Data, DelegateCtx, Env, Event, EventCtx, LayoutCtx, Lens, LifeCycle, LifeCycleCtx, LocalizedString, PaintCtx, Rect, ...
true
3b1588d9d8b34c59ff3a4fc196b5789aa6836053
Rust
vernonrj/MIPSical
/src/error.rs
UTF-8
1,202
3.28125
3
[ "MIT" ]
permissive
use std::error; use std::fmt; pub enum ExecResult<T> { Success(T), Empty, Exception(ExecError), } impl<T> ExecResult<T> { pub fn unwrap(self) -> T { match self { ExecResult::Success(t) => t, ExecResult::Empty => panic!("unwrap on Empty"), ExecResult::Excepti...
true
463df0da30e6abc30ed15757a77e6bc246bacd8b
Rust
PSeitz/rust-hdbconnect
/src/conn/params/into_connect_params_builder.rs
UTF-8
4,274
2.9375
3
[ "MIT", "Apache-2.0" ]
permissive
use super::connect_params::ServerCerts; use super::connect_params_builder::ConnectParamsBuilder; use super::cp_url; use crate::{HdbError, HdbResult}; use url::Url; /// A trait implemented by types that can be converted into a `ConnectParamsBuilder`. /// /// # Example /// ```rust /// use hdbconnect::IntoConnectPara...
true
61a9f412f26bf77761bf89f48ee3a534e7fdced9
Rust
Valentine-Mario/Spacies
/server/src/controllers/user_controller.rs
UTF-8
9,032
2.546875
3
[]
no_license
use crate::auth; use crate::diesel::QueryDsl; use crate::diesel::RunQueryDsl; use crate::handlers::types::*; use crate::helpers::{bcrypt, email, email_template}; use crate::model::{NewUser, User}; use crate::schema::users::dsl::*; use crate::Pool; use actix_web::web; use diesel::dsl::insert_into; use diesel::prelude::...
true
c0382c18460e7ad5be3004f6b84f7163a60c1eba
Rust
togdon/adventofcode_2020
/src/bin/day17-2.rs
UTF-8
1,517
2.84375
3
[]
no_license
use std::collections::{HashMap, HashSet}; use std::fs; #[macro_use] extern crate itertools; fn main() { let rawdata = fs::read_to_string("data/day-17.txt").expect("Unable to read file"); let data: Vec<&str> = rawdata.lines().collect(); // Initialize the space let mut cube_map = HashSet::new(); fo...
true
a5c5e15d0ca273d897d4dca88ecd5d9f094c5d28
Rust
BenChaimberg/rust-http-server
/src/parse.rs
UTF-8
335
2.84375
3
[]
no_license
pub fn discard_string<'a>(to_find: &str, s: &'a str) -> Result<&'a str, ()> { if s.starts_with(to_find) { Ok(&s[to_find.len()..]) } else { Err(()) } } pub fn discard_char(to_find: char, s: &str) -> Result<&str, ()> { if s.starts_with(to_find) { Ok(&s[1..]) } else { E...
true
70a3c0489087a3b59ecfad80bddc2aa66085990f
Rust
lapty/so
/src/tui/enumerable.rs
UTF-8
310
2.90625
3
[ "MIT" ]
permissive
/// Borrowed from Haskell /// Should be possible to auto derive pub trait Enum: Sized { fn to_enum(&self) -> u8; fn from_enum(i: u8) -> Self; fn succ(&self) -> Self { Self::from_enum(self.to_enum() + 1) } fn pred(&self) -> Self { Self::from_enum(self.to_enum() - 1) } }
true
be62be20f9b4061ab2ce29b4a1e5eebf7b5eaded
Rust
kgwong/ludum-dare-42
/src/anim.rs
UTF-8
1,351
3.140625
3
[]
no_license
use ggez::graphics; use ggez::Context; use ggez::GameResult; pub struct Anim { pos_x: f32, pos_y: f32, frame: u32, end: u32, wait: u32, //sprite: graphics::Image, is_dead: bool, prefix: String, } impl Anim { pub fn new( ctx: &mut Context, pos_x: f32, pos_y: f32, prefix: String, end...
true
166d83469579c8627fb5d8d7543112630c038020
Rust
zhongds/rust-oauth
/oauth/tests11/oauth2client_test.rs
UTF-8
804
2.6875
3
[]
no_license
// use oauth::{Oauth2client, Config, Oauth2clientTrait}; // #[test] // fn test_oauth2client_get_token() { // let conf = Config{ // api_origin: String::from("api_origin1"), // client_id: String::from("clientid"), // client_secret: String::from("client_secret"), // token_end_point: String::from("token_...
true
0046b88dd45b6289e7e2d0482022accf368d694f
Rust
GrossBetruger/CrackingTheJobInterview
/src/graphs.rs
UTF-8
1,905
2.90625
3
[]
no_license
use petgraph::graph::{NodeIndex, Graph, Neighbors}; use petgraph::Direction; use queues::{Queue, IsQueue}; use std::collections::{HashMap, HashSet}; use petgraph::visit::FilterNode; use petgraph::data::Element::Node; use queues::*; fn handle_neighbors(queue: & mut Queue<NodeIndex>, visited: &HashSet<NodeIndex>, ...
true
85dc4dafe02971856422e5f211521902dd8052f2
Rust
danno131313/dfile-rs
/src/main.rs
UTF-8
2,021
2.796875
3
[]
no_license
extern crate git2; extern crate glob; #[macro_use] pub extern crate structopt; extern crate time; use commands::{git_update, process_files, run_git}; use git2::Repository; use setup::new_git; use std::env::var; use std::process::exit; use structopt::StructOpt; mod commands; mod setup; /// A program to easily hardlin...
true
0d66eb6bec6aea1380d848aedef0fefa3d0f9a5c
Rust
9lung/rust
/vector/main.rs
UTF-8
937
3.125
3
[]
no_license
use std::{ alloc::*, slice, }; struct Vec { data : Box<[isize]>, length : usize, capacity : usize, } fn vec_new() -> Vec { Vec { data: Box::new([-1]), length: 0, capacity: 1, } } fn vec_push(vec: &mut Vec , n: isize) { if vec.length == vec.capacity { ...
true
c7c3af43f2785359569ea8c719cb2bcd7bbdbb6b
Rust
compactcode/exercism
/rust/proverb/src/lib.rs
UTF-8
540
2.953125
3
[]
no_license
use std::iter::once; pub fn build_proverb(list: Vec<&str>) -> String { match list.first() { Some(first) => list .windows(2) .map(format_pair) .chain(once(format_end(first))) .collect::<Vec<String>>() .join("\n"), None => String::new() ...
true
5205b10e6f446cbf041bcf6de8a3818dd7c4eb12
Rust
Genomicsplc/rusqlite
/src/util/sqlite_string.rs
UTF-8
8,737
3.203125
3
[ "MIT", "LicenseRef-scancode-public-domain", "BSD-3-Clause" ]
permissive
// This is used when either vtab or modern-sqlite is on. Different methods are // used in each feature. Avoid having to track this for each function. We will // still warn for anything that's not used by either, though. #![cfg_attr( not(all(feature = "vtab", feature = "modern-sqlite")), allow(dead_code) )] use ...
true
4e599b832d900978059b694a8a276a20e0cfc54b
Rust
chadrc/expression-lang
/expr_lang_common/src/value/range.rs
UTF-8
2,973
3.0625
3
[]
no_license
pub const RANGE_START_EXCLUSIVE: u8 = 1; pub const RANGE_END_EXCLUSIVE: u8 = 1 << 1; pub const RANGE_OPEN_START: u8 = 1 << 2; pub const RANGE_OPEN_END: u8 = 1 << 3; pub const RANGE_HAS_STEP: u8 = 1 << 4; pub fn has_step(flags: u8) -> bool { flags & RANGE_HAS_STEP == RANGE_HAS_STEP } pub fn has_start(flags: u8) ->...
true
c1da20b45ee9017765edc14b32409665cd4d50f7
Rust
Malique-Auguste/RobotCar
/src/car_control.rs
UTF-8
1,299
3
3
[]
no_license
use crate::traits::Controller; use crate::direction::Direction; use std::io; use std::fmt; use termion::event::Key; use termion::input::TermRead; use termion::raw::IntoRawMode; use std::io::{Write, stdout, stdin}; pub struct CarController { last_direction: Direction, current_direction: Direction } impl CarCon...
true
543245dca367f9838454a8f2f2cc811ce3acc77e
Rust
remunds/pasture
/pasture-derive/src/layout.rs
UTF-8
5,400
3.125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use syn::{Attribute, DataStruct, Error}; use syn::{NestedMeta, Result}; #[derive(Debug)] pub(crate) enum StructMemberLayout { C, Packed(u64), } /// Is the given Attribute a #[repr(...)] attribute? fn is_repr_attribute(attribute: &Attribute) -> bool { attribute .path .get_ident() .m...
true
fe1c71bb5c1bc3010c72bf03696173607b30baa2
Rust
fossabot/sahke
/src/requests/payloads/send_contact.rs
UTF-8
3,339
3
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; use crate::{ requests::{dynamic, json, Method}, types::{ChatId, ReplyMarkup, Message}, }; /// Use this method to send phone contacts. On success, the sent Message is returned. #[serde_with_macros::skip_serializing_none] #[derive(Debug, PartialEq, Eq, Hash, Clone, Deseriali...
true
eb09b9c460b9b4b38a1f5f55a6f87b9b086d3ee0
Rust
na--/dev-exercises
/rust-fmi-course/solutions/02/tests/my_tests.rs
UTF-8
2,509
3.0625
3
[]
no_license
extern crate solution; use solution::Polynomial; #[test] fn test_simple_functions() { assert_eq!(Polynomial::from(vec![]), Polynomial::from(vec![])); assert_eq!(Polynomial::from(vec![]), Polynomial::from(vec![0.0])); assert_eq!(Polynomial::from(vec![]), Polynomial::from(vec![0.0, 0.0])); assert_eq!( ...
true
4c6cdbf3a89591bef13142516449012ec4421b15
Rust
ecafkoob/ockam
/implementations/rust/ockam/signature_core/src/signature_blinding.rs
UTF-8
1,468
2.84375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::util::*; use bls12_381_plus::Scalar; use ff::Field; use rand_core::RngCore; use serde::{Deserialize, Serialize}; use subtle::CtOption; /// A message that is signed into a signature #[derive(Debug, Copy, Clone, Eq, PartialEq, Deserialize, Serialize)] pub struct SignatureBlinding(pub Scalar); impl SignatureB...
true
e31231275708d8177d84a76cd9b4d1ea89e5f8d6
Rust
Deisss/watchexec
/src/error.rs
UTF-8
2,419
2.9375
3
[ "Apache-2.0" ]
permissive
use std::{error::Error as StdError, fmt, io, sync::PoisonError}; pub type Result<T> = ::std::result::Result<T, Error>; pub enum Error { Canonicalization(String, io::Error), Clap(clap::Error), Glob(globset::Error), Io(io::Error), Notify(notify::Error), PoisonedLock, } impl StdError for Error {...
true
0f682d2e76d0ff565c1c4773eb9e84a00a65faa8
Rust
nornagon/automerge-rs
/automerge-protocol/src/utility_impls/element_id.rs
UTF-8
821
2.53125
3
[ "MIT" ]
permissive
use crate::error::InvalidElementID; use crate::{ElementID, OpID}; use std::{convert::TryFrom, str::FromStr}; impl From<OpID> for ElementID { fn from(o: OpID) -> Self { ElementID::ID(o) } } impl From<&OpID> for ElementID { fn from(o: &OpID) -> Self { ElementID::ID(o.clone()) } } impl F...
true
78510ad0389a0cfe89ab5628e5b69fcd810cac39
Rust
SpaceManiac/discord-rs
/examples/login_cache.rs
UTF-8
705
2.796875
3
[ "MIT" ]
permissive
extern crate discord; use discord::Discord; use std::env; #[allow(deprecated)] fn main() { // To see the token cache in action, try the following sequence of commands: // $ cargo run --example login_cache <email> // The login will fail because no password was specified. // $ cargo run --example login_cache <email...
true
10a7808833da325f5236e541be87434991e9a03c
Rust
Krout0n/go-parser-rs
/src/literals/integer.rs
UTF-8
7,679
3.59375
4
[ "MIT" ]
permissive
use nom::{ branch::alt, bytes::complete::tag, character::complete::{one_of, space0}, combinator::{map, not, opt, recognize}, multi::many0, sequence::{pair, tuple}, IResult, }; use super::letter_and_digit::{binary_digit, decimal_digit, hex_digit, octal_digit}; #[derive(Debug, PartialEq)] pu...
true
ec9e27dc6e3601024fab58ec729801b52e31fe24
Rust
pie-flavor/lpc176x-5x
/src/usb/i2c_sts.rs
UTF-8
18,705
2.6875
3
[ "WTFPL" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } impl super::I2C_STS { #[doc = r" Reads the contents of the register"] #[inline] pub fn read(&self) -> R { R { bits: self.register.get(), } } } #[doc = "Possible values of the field `TDI`"] #[derive(Clon...
true
4bc6da9f8ee31c4915b975fb8e47047b216cd2db
Rust
filippixavier/AoC2018
/src/days/day25.rs
UTF-8
2,062
3.09375
3
[]
no_license
extern crate regex; use std::error::Error; use std::fs; use std::path::Path; use self::regex::Regex; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] struct SpaceTimePoint { x: i32, y: i32, z: i32, t: i32, } impl SpaceTimePoint { fn manhattan_dist(&self, other: &SpaceTimePoint) -> i32 { ...
true
c6709071851ec372bf698368a4f30ee0f101201b
Rust
scalefactory/s3du
/src/common/object_versions.rs
UTF-8
1,013
3.125
3
[ "Apache-2.0", "MIT" ]
permissive
// ObjectVersions #![forbid(unsafe_code)] #![deny(missing_docs)] use anyhow::Result; use std::str::FromStr; /// `ObjectVersions` represents which objects we're going to sum when /// operating in S3 mode. #[derive(Debug)] pub enum ObjectVersions { /// Sum size of all object versions (both `Current` and `NonCurrent`...
true
6f770f86d174da4e5b5fcd3bdc0f56527095d474
Rust
haumea-lang/haumea-rs
/tests/test_scanner.rs
UTF-8
1,847
3.484375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Tests for `haumea::scanner` extern crate haumea; use haumea::scanner::*; use haumea::scanner::Token::*; fn assert_scan_is(source: &str, expected: Vec<Token>) { let scanner = Scanner::new(source); let found: Vec<Token> = scanner.collect(); assert_eq!(found, expected); } #[test] fn test_scanner_simple()...
true
6230a58db567d86ffa598a270d1a8b0880aac7e3
Rust
louiidev/deckbuilding-roguelike
/src/cards.rs
UTF-8
400
2.71875
3
[ "MIT" ]
permissive
use crate::{CardID, CardDB}; use crate::components::Card; use rand::{thread_rng, Rng}; pub fn generate_intial_deck(cards_db: &CardDB) -> Vec<CardID> { let mut deck = Vec::new(); let mut rng = rand::thread_rng(); for _ in 0..10 { let index = rng.gen_range(0, cards_db.len()); let card = c...
true
526343149a03ebf92a73bfa932a0ee55ae33defb
Rust
jonwingfield/atsamd09-rs
/atsamd09d14a/adc/refctrl/mod.rs
UTF-8
7,175
2.75
3
[]
no_license
#[doc = r" Value read from the register"] pub struct R { bits: u8, } #[doc = r" Value to write to the register"] pub struct W { bits: u8, } impl super::REFCTRL { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut...
true
d2312b02b43aedfdca5cee91556e05b03e116250
Rust
whachoe/zerotierDNS
/src/BytePacketBuffer.rs
UTF-8
5,570
3.4375
3
[ "MIT" ]
permissive
use std::io::{Result}; use std::io::{Error, ErrorKind}; pub struct BytePacketBuffer { pub buf: [u8; 512], pub pos: usize } impl BytePacketBuffer { pub fn new() -> BytePacketBuffer { BytePacketBuffer { buf: [0; 512], pos: 0 } } pub fn pos(&self) -> usize { ...
true
39bd251894a44c5d52e1e66c40709ebe995c0e10
Rust
stuartstein777/CodeWars
/8KYU/Get planet name by ID/solution.rs
UTF-8
369
2.90625
3
[]
no_license
fn get_planet_name(id: u32) -> String { match id { 1 => "Mercury".to_string(), 2 => "Venus".to_string(), 3 => "Earth".to_string(), 4 => "Mars".to_string(), 5 => "Jupiter".to_string(), 6 => "Saturn".to_string(), 7 => "Uranus".to_string(), 8 => "Neptune"...
true
01e477ece0f0c3163b2a24323e4d6ea5c3799b31
Rust
Rene-Ulmer/Tropical-Frency
/src/camera.rs
UTF-8
571
2.90625
3
[]
no_license
use common::AbsolutePosition; use HEIGHT; use WIDTH; // TODO: Shaking etc. pub struct Camera { position: AbsolutePosition, } impl Camera { pub fn new() -> Self { Self { position: AbsolutePosition(0f32, 0f32), } } pub fn get(&self) -> AbsolutePosition { self.positi...
true
67a98e6508e91f463cf0dd35dcdbf6484a1657ab
Rust
Byron/gitoxide
/gix-pathspec/src/search/mod.rs
UTF-8
1,812
2.734375
3
[ "MIT", "Apache-2.0" ]
permissive
use bstr::{BStr, ByteSlice}; use crate::{Pattern, Search}; /// Describes a matching pattern within a search for ignored paths. #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] pub struct Match<'a> { /// The matching search specification, which contains the pathspec as well. pub pattern: &'a Patte...
true
c3ed31c41ed2ce666614eced85c7d0231bb4820b
Rust
sadroeck/Heimdall-RS
/api/src/codec.rs
UTF-8
2,281
2.796875
3
[]
no_license
use crate::map::Maps; use std::time::SystemTime; pub trait RagnarokCodec { fn encode<T: EncodeFixed>(&mut self, val: &T); fn encode_struct<T: EncodeStruct>(&mut self, val: &T); fn padding(&mut self, count: usize); // Resource access fn maps(&self) -> &Maps; } pub trait EncodeFixed { const SIZ...
true
dcfd37194f163d8dd5bd5bfbaecfe70a2950a89a
Rust
jfrimmel/rust
/tests/ui/offset-of/offset-of-tuple.rs
UTF-8
401
2.5625
3
[ "LLVM-exception", "Apache-2.0", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
#![feature(offset_of)] #![feature(builtin_syntax)] fn main() { core::mem::offset_of!((u8, u8), _0); //~ ERROR no field `_0` core::mem::offset_of!((u8, u8), +1); //~ ERROR no rules expected core::mem::offset_of!((u8, u8), -1); //~ ERROR no rules expected builtin # offset_of((u8, u8), _0); //~ ERROR no f...
true
dd6f4579dd4be789feb13e043d442aa59cd806ec
Rust
Jayshua/rust-peg
/src/lib.rs
UTF-8
1,821
2.671875
3
[ "MIT" ]
permissive
#![recursion_limit = "192"] #[macro_use] extern crate quote; use std::io; use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::convert::AsRef; use std::fs::File; use std::process::exit; use std::env; mod translate; mod grammar; /// Compile a peg grammar to Rust source pub fn compile(input: &str) -> Res...
true
0b08f85532343599c6c335b925a95a99c54e60e1
Rust
likr/atcoder
/abc095/src/bin/d.rs
UTF-8
1,437
2.765625
3
[]
no_license
use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::consts::*; #[allow(unused)] const INF: usize = std::usize::MAX / 4; #[allow(unused)] const M: usize = 1000000007; fn...
true
e5e0bfc8432aec608b06d9a6788074b4811949e8
Rust
skillzaa/qndr
/tests/alphabets_with_symbols.rs
UTF-8
1,356
3.203125
3
[]
no_license
use qndr; #[cfg(test)] #[test] fn a() { let r = qndr::alphabets_with_symbols(&String::from("?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),&String::from("?")); assert_eq!(true,r); } #[cfg(test)] #[test] fn b() { let r = qndr::alphabets_with_symbols(&String::from("abc!dew@s"),&String::from("!@#")); a...
true
566d8c4643f3673e179f8a9390b71041fe083fb4
Rust
fazibear/code_forces
/src/4A_Watermelon.rs
UTF-8
250
2.953125
3
[]
no_license
fn main() { let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).unwrap(); let x = buffer.trim().parse::<i64>().unwrap(); if x % 2 == 0 && x != 2{ println!("YES") } else { println!("NO") } }
true
36f4869abd08fdd9032b012e6c154da5fc8b62e4
Rust
tailhook/bulk
/src/repo/ar.rs
UTF-8
2,010
3.125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::io::{self, Read, Take}; use std::str; use std::path::Path; use std::os::unix::ffi::OsStrExt; pub struct Archive<T:Read>(T, bool); fn error(text: &'static str) -> io::Error { return io::Error::new(io::ErrorKind::Other, text); } impl<T:Read> Archive<T> { pub fn new(mut stream: T) -> io::Result<Archi...
true
26d6438c5e3adc4f2bb663d1458366df37050056
Rust
prisma/prisma-engines
/schema-engine/sql-migration-tests/tests/evaluate_data_loss/evaluate_data_loss_tests.rs
UTF-8
7,243
2.640625
3
[ "Apache-2.0" ]
permissive
use sql_migration_tests::test_api::*; #[test_connector] fn evaluate_data_loss_with_an_up_to_date_database_returns_no_step(api: TestApi) { let dm = api.datamodel_with_provider( r#" model Cat { id Int @id name String } "#, ); let directory = api.create_mig...
true
fc1ff60fe5a686c78b281ed225f68a7b5eb3545e
Rust
nmccarty/asuran
/asuran/benches/archive.rs
UTF-8
5,975
2.546875
3
[ "BSD-3-Clause", "BSD-2-Clause-Patent" ]
permissive
use asuran::chunker::*; use asuran::manifest::archive::Extent; use asuran::manifest::*; use asuran::repository::backend::mem::Mem; use asuran::repository::*; use criterion::*; use rand::prelude::*; use std::thread; use std::time::Duration; // Quick and dirty compressible random data generation // Uses a counter with c...
true
cab48148ac02aea3ae1b3c0300ca1bd1242e164a
Rust
EFanZh/LeetCode
/src/problem_0406_queue_reconstruction_by_height/binary_search_tree.rs
UTF-8
2,545
3.34375
3
[]
no_license
pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // use std::cmp::Reverse; use std::convert::TryInto; use std::mem; struct Node { length: usize, value: Vec<i32>, left: Option<Box<Node>>, right: Option<Box<Node>>...
true
808bcf83d3ba54ebedb7b80431f8e28417054ceb
Rust
sadroeck/Heimdall-RS
/databases/src/character/in_memory.rs
UTF-8
3,758
3.046875
3
[]
no_license
use api::{ account::db::AccountId, character::{ db::{CharacterDB, CharacterId, DBError, DBResult}, Character, }, }; use async_std::sync::RwLock; use std::collections::{hash_map::Entry, HashMap}; use tracing::{debug, info}; pub struct InMemoryCharacterDB { verbose: bool, characters: ...
true
ee8da2d5966f831f92582d58614a84c2e2cd8c55
Rust
MindFlavor/azure-sdk-for-rust
/sdk/storage/src/core/copy_id.rs
UTF-8
1,444
2.75
3
[ "MIT", "LicenseRef-scancode-generic-cla", "LGPL-2.1-or-later" ]
permissive
use http::HeaderMap; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::convert::TryFrom; use std::fmt; use super::headers::COPY_ID; #[derive(Debug, Clone, PartialEq, Eq)] pub struct CopyId(uuid::Uuid); pub fn copy_id_from_headers(headers: &HeaderMap) -> crate::Result<CopyId> { let copy_id =...
true
a0e3b2f5311ee59240ca26dd9f54a09442be558f
Rust
0b01/fastwfc-rs
/fastwfc/src/lib.rs
UTF-8
4,951
2.84375
3
[]
no_license
extern crate fastwfc_sys; extern crate image; use fastwfc_sys::run_overlapping; fn to_array_color_2d(input: image::RgbaImage) -> *mut fastwfc_sys::ArrayColor2D { let (w, h) = input.dimensions(); let obj = Box::new(input.into_vec()); let arr: *const u8 = obj.as_ptr(); // TODO: memory leak let ptr = Box...
true
c9571236d5749140a63f34ee5f0382b0963335e9
Rust
JacobSchneck/rust_graphs
/src/main.rs
UTF-8
2,474
3
3
[]
no_license
// use graphs::edge::Edge; use graphs::edge::Edge; use graphs::graph::Graph; use graphs::weighted_edge::WeightedEdge; use graphs::weighted_graph::WeightedGraph; use std::env; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn main() { let args: Vec<String> = env::args().collect(); let f...
true
b0427001df8766386b52779f9542b5c076d8faab
Rust
dunrix/unixbar
/src/widget/text.rs
UTF-8
347
2.734375
3
[ "Unlicense", "LicenseRef-scancode-public-domain" ]
permissive
use super::base::{Sender, Widget}; use format::data::Format; pub struct Text { text: Format, } impl Widget for Text { fn current_value(&self) -> Format { self.text.clone() } fn spawn_notifier(&mut self, _: Sender<()>) {} } impl Text { pub fn new(text: Format) -> Box<Text> { Box::...
true
54c75cb68f90ed54a21e6ccf9fc7a4029c9c02ce
Rust
agubelu/ray-tracing
/src/data/vec3.rs
UTF-8
4,583
3.265625
3
[]
no_license
use overload::overload; use serde::Deserialize; use std::ops; // This type controls the float precision used throughout the project pub type RTFloat = f64; pub type Color = Vec3; pub type Point = Vec3; const NEAR_ZERO: RTFloat = 1e-8; #[derive(Debug, Copy, Clone, PartialEq, Deserialize)] pub struct Vec3 ([RTFloat; ...
true
35086e941b0053457de3324bdd176fc04eb89e24
Rust
Ktwu/aoc2020
/src/day3.rs
UTF-8
2,719
3.265625
3
[]
no_license
#![allow(dead_code)] use crate::{utils, utils::AOCError}; pub struct Trajectory { right: usize, down: usize, tree_count: u64, right_offset: usize, to_skip: usize, } impl Trajectory { fn new(right: usize, down: usize) -> Self { Trajectory { right, down, ...
true
081abfae1f26b8cdfbe1ae0d0944c8536eb72a43
Rust
lskatz/fasten
/src/bin/fasten_sort.rs
UTF-8
9,297
3.03125
3
[ "MIT" ]
permissive
//! Sort a fastq file. //! If the reads are paired end, then the sorted field //! concatenates R1 and R2 before comparisons in the sort. //! R1 and R2 reads will stay together if paired end. //! //! Sorting by GC content will give better compression by magic of gzip //! and other algorithms. //! //! Sorting can also...
true
d539a9573ce2ff4e4602110bab625f8f46622022
Rust
kitty-lang/shedder
/src/parser/expr.rs
UTF-8
9,551
2.640625
3
[ "MIT" ]
permissive
use std::fmt; use std::fmt::Display; use std::fmt::Formatter; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use crate::lexer; use crate::lexer::Ident; use crate::lexer::Symbol; use crate::lexer::Token; use crate::lexer::TokenTy; use crate::lexer::TokenVariant; use super::split; use super::try_e...
true
461493056aa44a0937a1da87ec4b40bbe5fc02bb
Rust
tyler274/tray_rust
/src/film/mod.rs
UTF-8
1,074
2.96875
3
[ "MIT" ]
permissive
//! The film module provides color types and a render target that the image //! is written too. pub use self::animated_color::{AnimatedColor, ColorKeyframe}; pub use self::camera::Camera; pub use self::color::Colorf; pub use self::image::Image; pub use self::render_target::ImageSample; pub use self::render_target::Ren...
true
4e59f1443948047fb176a2e67cbe8b7d03bec253
Rust
buroz/dadavanga
/src/main.rs
UTF-8
2,425
3.25
3
[]
no_license
extern crate clap; extern crate rand; use clap::{App, Arg}; use rand::Rng; use std::str::FromStr; use std::{ fs::File, io::{prelude::*, BufReader}, path::Path, }; fn lines_from_file(filename: impl AsRef<Path>) -> Vec<String> { let file = File::open(filename).expect("no such file"); let buf = BufRe...
true
3385614bec44f40913eaf4f0fe884bb3ebbefe68
Rust
abjordan/advent-of-code-2018
/day01/day-01a/src/main.rs
UTF-8
490
2.890625
3
[ "BSD-2-Clause" ]
permissive
use std::env; use std::fs::File; use std::io::{BufRead, BufReader, Result}; fn main() -> Result<()> { let args: Vec<String> = env::args().collect(); let filename = &args[1]; let file = File::open(filename)?; let mut total = 0; for line in BufReader::new(file).lines() { let line = line.expect("Unable...
true
7754e5a809ffa9fe68c22842e92b9448b3bf46b5
Rust
yecanlin/rust
/p14_performance_test/src/main.rs
UTF-8
108
2.546875
3
[]
no_license
fn main() { let buffer: &mut [i32]; for i in 12..buffer.len() { println!("{}", i); } }
true
24906f1254167b06f04faaa9416e2661f7ed1b1e
Rust
tbauer428/gamepad_input
/src/main.rs
UTF-8
3,460
2.921875
3
[ "MIT" ]
permissive
use gilrs::{Button, EventType, Gilrs}; use url::Url; use tungstenite::{connect, Message, WebSocket}; use std::thread; use std::time::Duration; use tungstenite::client::AutoStream; fn main() { let (mut socket, response) = connect(Url::parse("ws://192.168.1.54:8080").unwrap()).expect("Can't connect"); ...
true
8b9158913140dec7831e51dfe2a95f9b2817151c
Rust
Weasy666/egui
/crates/egui_demo_lib/src/easy_mark/easy_mark_parser.rs
UTF-8
11,190
3.625
4
[ "MIT", "Apache-2.0" ]
permissive
//! A parser for `EasyMark`: a very simple markup language. //! //! WARNING: `EasyMark` is subject to change. // //! # `EasyMark` design goals: //! 1. easy to parse //! 2. easy to learn //! 3. similar to markdown #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Item<'a> { /// `\n` // TODO(emilk): add Styl...
true
926fbc265348c169ccb0fa9989ae4612a850d175
Rust
myarchsource/rust
/vendor/elasticlunr-rs/src/inverted_index.rs
UTF-8
12,193
3.09375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
//! Implements an elasticlunr.js inverted index. Most users do not need to use this module directly. use std::collections::BTreeMap; #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] struct TermFrequency { #[serde(rename = "tf")] pub term_freq: f64, } #[derive(Serialize, Deserialize,...
true
66fe21b74814ada57670d58ebc5e2d7f55a9863a
Rust
Wdiviner/geektime-rust
/12_type_system/src/constant.rs
UTF-8
203
2.71875
3
[ "Apache-2.0" ]
permissive
const PI: f64 = std::f64::consts::PI; static E: f32 = std::f32::consts::E; fn main() { const V: u32 = 10; static V1: &str = "hello"; println!("PI: {}, E: {}, V {}, V1: {}", PI, E, V, V1); }
true
e71623a2de5b46cb5b0cb3d987c21ec4e8407934
Rust
fxwiegand/advent-of-code-2020
/src/days/day9.rs
UTF-8
1,283
2.953125
3
[]
no_license
use itertools::Itertools; use std::str::FromStr; pub(crate) fn solve_day9() -> u64 { let input_file = include_str!("../resources/day9.txt"); let numbers = input_file .lines() .map(|n| u64::from_str(n).unwrap()) .collect_vec(); let mut result = 0; 'outer: for (index, n) in numb...
true
3819e4dc8dc537096b2b4c2f3368035c179c056b
Rust
JADSN/typed-sql
/src/types/chrono.rs
UTF-8
1,004
2.875
3
[ "MIT" ]
permissive
use super::Primitive; use chrono::{DateTime, Local, NaiveDate, NaiveDateTime, NaiveTime, Utc}; impl Primitive for DateTime<Utc> { fn write_primative(&self, sql: &mut String) { sql.push('\''); sql.push_str(&self.to_string()); sql.push('\''); } } impl Primitive for DateTime<Local> { ...
true
89f99ac6d827f7dbf042ccd2b7035d838ea57dd9
Rust
ackintosh/sandbox
/rust/coursera-algorithmic-toolbox/week1-2-maximum-pairwise-product/src/main.rs
UTF-8
3,577
3.25
3
[]
no_license
// https://www.coursera.org/learn/algorithmic-toolbox/programming/Xscmz/programming-assignment-1-maximum-pairwise-product // use rand::Rng; use std::convert::TryFrom; use std::str::FromStr; fn main() { let n = { let mut buff = String::new(); std::io::stdin().read_line(&mut buff).unwrap(); ...
true
1a86debe2b79b5b1fa681ef6fb79f35c9fce0376
Rust
pierrechevalier83/unicode_types
/src/generated/supplemental_arrows_c.rs
UTF-8
36,175
2.984375
3
[ "LicenseRef-scancode-unicode" ]
permissive
/// An enum to represent all characters in the SupplementalArrowsC block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum SupplementalArrowsC { /// \u{1f800}: '🠀' LeftwardsArrowWithSmallTriangleArrowhead, /// \u{1f801}: '🠁' UpwardsArrowWithSmallTriangleArrowhead, /// \u{1f802}: '🠂' ...
true
c9bf82ef26b17d555555ea242b357c74be680bb8
Rust
pbnj-io/aeon
/vm/src/virtual_machine.rs
UTF-8
92,170
2.578125
3
[]
no_license
//! Virtual Machine for running instructions //! //! A VirtualMachine manages threads, runs instructions, starts/terminates //! threads and so on. VirtualMachine instances are fully self contained //! allowing multiple instances to run fully isolated in the same process. use std::collections::HashSet; use std::io::{se...
true
7c39a73025314e2758cb9a1298dc865afbcf3332
Rust
isgasho/bonsaidb
/core/src/connection.rs
UTF-8
19,611
2.5625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::{borrow::Cow, marker::PhantomData, ops::Range}; use async_trait::async_trait; use custodian_password::{ ClientConfig, ClientFile, ClientRegistration, RegistrationFinalization, RegistrationRequest, RegistrationResponse, }; use serde::{Deserialize, Serialize}; use crate::{ document::{Document, Head...
true
a4a8cf4c607789187e7e734e1dc07ac290ab995f
Rust
jaskirat1208/rusty-games
/src/traits.rs
UTF-8
1,027
2.984375
3
[]
no_license
pub mod game_traits { pub trait Start { fn init(&mut self); } pub trait Update { fn update(&mut self); } pub trait Terminate { fn can_terminate(&self) -> bool; fn handle_terminate(&self); } } pub mod player_traits { pub trait Play<PlayerMove> { fn...
true
c15fca0851fbcedf7a4435ac8bfa95ff4ae2e48e
Rust
kotamat/rust_tutorial
/generics/src/lifetime.rs
UTF-8
3,810
3.671875
4
[]
no_license
use std::fmt::Display; use crate::largest; pub(crate) fn main() { generic_lifetimes_in_functions(); lifetime_annotations_restrict(); lifetime_annotations_in(); lifetime_annotations_with_struct(); } // fn borrow_live_long() { // { // let r; // { // let x = 5; // ...
true
ea31ee5ab125915f9228704532fcf819ea733cd5
Rust
yiwang/sgf-parser
/src/tree.rs
UTF-8
8,280
3.4375
3
[]
no_license
use crate::{GameNode, SgfError, SgfErrorKind, SgfToken}; /// A game tree, containing it's nodes and possible variations following the last node #[derive(Debug, Clone, PartialEq)] pub struct GameTree { pub nodes: Vec<GameNode>, pub variations: Vec<GameTree>, } impl Default for GameTree { /// Creates an emp...
true
dbb05922b1c5d27a961e59214464f7a2eda18e05
Rust
sigod/codewars
/src/reversed-sequence.rs
UTF-8
233
3.328125
3
[ "MIT" ]
permissive
fn reverse_seq(n: u32) -> Vec<u32> { let mut result = Vec::with_capacity(n as usize); for value in 0..n { result.push(n - value); } result } #[test] fn sample_test() { assert_eq!(reverse_seq(5), [5, 4, 3, 2, 1].to_vec()); }
true
c0aac76f14f460556dab637badac42ddd12721d1
Rust
senofsky/project-euler
/rust/src/2.rs
UTF-8
607
3.859375
4
[ "MIT" ]
permissive
// Each new term in the Fibonacci sequence is generated by adding the previous two terms. By // starting with 1 and 2, the first 10 terms will be: // // 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... // // By considering the terms in the Fibonacci sequence whose values do not exceed four million, find // the sum of the even-...
true
b5fb5ebff8a763f6bad3431d7db0bf1cb11ae703
Rust
jpetracci/aoc
/2022/day1/src/main.rs
UTF-8
958
3.421875
3
[]
no_license
use std::fs; fn main() { let values = fs::read_to_string("day1_input.txt").expect("error reading file"); let values = values.split("\n"); let values = values.collect::<Vec<&str>>(); part1(values.clone()); part2(values); } fn part1(values: Vec<&str>) { let mut largest = 0; let mut sum = 0; ...
true
0f4ba3354eb7bf9ad73b96305761519ac688c365
Rust
mafm/voile-rs
/src/syntax/core/pretty.rs
UTF-8
2,566
2.90625
3
[ "Apache-2.0" ]
permissive
use std::fmt::{Display, Error, Formatter}; use crate::syntax::common::DtKind::*; use super::{Axiom, Closure, Neutral, Val, ValInfo}; impl Display for Neutral { fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { use Neutral::*; match self { Var(dbi) => write!(f, "[{}]", dbi), ...
true
18b30e4e7c5b896f90c9c825b9216046dcd1f3d2
Rust
aatxe/awebot-plugins
/ddg/src/lib.rs
UTF-8
5,214
2.8125
3
[]
no_license
extern crate irc; extern crate url; use irc::client::prelude::*; use irc::error; use irc::proto::Command::PRIVMSG; use url::Url; use url::percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET}; #[no_mangle] pub extern fn process(server: &IrcServer, message: &Message) -> error::Result<()> { process_internal(s...
true
cd146044676e1382a2bd32cbd7750c6b53b67372
Rust
birktj/dijkstra-controller-2019
/original/src/stepper.rs
UTF-8
2,562
2.78125
3
[]
no_license
use embedded_hal::timer::{CountDown, Periodic}; use embedded_hal::digital::{InputPin, OutputPin}; trait Component { type State; type Params; type Msg; fn init(params: Self::Params) -> Self::State; fn update(&mut self, msg: Self::Msg); fn step(&mut self); } fn step(&mut self) { if sel...
true
d484a002b0296a0312a5298e882b596453802d9a
Rust
MJR-Mu7/stateless-blockchain
/runtime/src/stateless.rs
UTF-8
11,493
2.703125
3
[ "Unlicense" ]
permissive
/// PROJECT: Stateless Blockchain Experiment. /// /// DESCRIPTION: This repository implements a UTXO-based stateless blockchain on Substrate using an /// RSA accumulator. In this scheme, validators only need to track a single accumulator value and /// users only need to store their own UTXOs and membership proofs. Unle...
true
cdb3179fcb849f80242859ac89ccb42b8ebe4db4
Rust
VadimGaltsev/rusty_cake
/rusty_cake/src/lib.rs
UTF-8
2,463
3.328125
3
[]
no_license
#[allow(unused_imports)] pub use builder::*; pub trait Builder<T> { type Builder; fn builder() -> Self::Builder; } #[macro_use] pub mod functional { /// # Examples /// Single variant /// ``` /// use rusty_cake::constr; /// /// struct A { /// value: String /// } /// /// let mut a_var = A { ...
true
a31e371f2d76917b407f5977e68aa6c839e8ab8b
Rust
qryxip/atcoder-rustc-dep-option-generator
/src/main.rs
UTF-8
6,658
2.65625
3
[ "MIT" ]
permissive
use cargo::core::manifest::{EitherManifest, Manifest}; use cargo::core::{Dependency as CargoDependency, GitReference, SourceId}; use cargo::util::config::Config; use cargo::util::toml::read_manifest; use std::env; use std::error::Error; use std::fs; use std::path::{Path, PathBuf}; type Result<T> = std::result::Result<...
true
7e85cff7d0f67bf2646b5ca9a77ae3782717f3ea
Rust
qqwa/rustos
/armv8_a/src/raw.rs
UTF-8
6,301
2.765625
3
[]
no_license
/// Read Register macro_rules! rreg { ( $(#[$m:meta])* $function:ident, $type:ty, $instruction:expr, $register:expr ) => { $(#[$m])* #[inline(always)] pub unsafe fn $function() -> $type { let ret: $type; asm!(concat!($instruction, " $0, ", ...
true
2031c447c733309ffac9bd0fd3b2a083d1411c31
Rust
nyorain/nodes-old
/src/node.rs
UTF-8
2,730
3.046875
3
[ "BSL-1.0" ]
permissive
use super::storage::Storage; use super::toml; use std::path::PathBuf; use std::fs; use std::io; pub struct Node<'a, 'b: 'a> { storage: &'a Storage<'b>, id: u64, archived: bool } impl<'a, 'b> Node<'a, 'b> { // use default argument instead? pub fn new(storage: &'a Storage<'b>, id: u64) -> Node<'a, ...
true
c688d29e95b0a61ee429386e19e0a0ed4fbd7ddc
Rust
chuckGonzalez/relay
/compiler/crates/graphql-transforms/src/handle_fields/handle_field_util.rs
UTF-8
5,684
2.6875
3
[ "MIT" ]
permissive
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use crate::handle_fields::HandleFieldConstants; use common::{Location, WithLocation}; use graphql_ir::{Argument, ConstantValue, Dir...
true
2a9b8186fcb0458a1346bfe58b18473efcb3ad4c
Rust
xg-zhang/learn_rust
/one_day/one_day.rs
UTF-8
448
3.4375
3
[]
no_license
fn main() { println!("hello world"); let number = 8; println!("The value of number is {}", number); //number = 9; let mut num = 10; num = 11; println!("The value of num is {}", num); let a_a_1 = 1; let _a1 = 2; //shadowing let a = 12; let a = 15; println...
true