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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
fb94baa70317854784ab8d3a89d1e0f3fbf1b1c9 | Rust | codyd51/axle | /rust_programs/libgui/src/button.rs | UTF-8 | 7,499 | 2.625 | 3 | [
"MIT"
] | permissive | use core::cell::RefCell;
use agx_definitions::{
Color, Drawable, LikeLayerSlice, Line, NestedLayerSlice, Point, Rect, RectInsets, Size,
StrokeThickness,
};
use alloc::boxed::Box;
use alloc::rc::Weak;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use crate::{bordered::Bordered, font::draw_char, u... | true |
f0ea1a6c88ccfc2df359d4eff8f012176ce0bd24 | Rust | inda20plusplus/maltebl-chess | /gui/src/state.rs | UTF-8 | 697 | 2.71875 | 3 | [] | no_license | use std::sync::Arc;
use maltebl_chess::board_logic::Board;
use maltebl_chess::piece_logic::Piece;
use druid::Data;
#[derive(Data, Copy, Clone, Debug, PartialEq)]
pub struct Position(pub i32, pub i32);
#[derive(Data, Clone)]
pub struct AppState {
pub board: Arc<Board>,
pub origin: Option<Position>,
pub m... | true |
51a75be22a36c8e4f9812014e4db539deb14a350 | Rust | EbTech/rust-algorithms | /src/graph/util.rs | UTF-8 | 6,361 | 3.03125 | 3 | [
"MIT"
] | permissive | use super::{DisjointSets, Graph};
use crate::graph::AdjListIterator;
use std::cmp::Reverse;
impl Graph {
/// Finds the sequence of edges in an Euler path starting from u, assuming
/// it exists and that the graph is directed. Undefined behavior if this
/// precondition is violated. To extend this to undire... | true |
a8b47cd7f600e7b50214efca31cbf692714f3e8c | Rust | ekroth/rusty-neuron | /src/util.rs | UTF-8 | 1,241 | 3.5625 | 4 | [] | no_license | use std::iter;
// Flatten Iterator of Result into Result of Vec
pub fn result_sequence<T, U, E>(items: T) -> Result<Vec<U>, E>
where T: iter::IntoIterator<Item=Result<U, E>>,
{
let mut rxs = Ok(vec![]);
for i in items {
let mut xs = try!(rxs);
let i = try!(i);
xs.push(i);
r... | true |
fd6fefa77cc6210171b213d395d72892de1c12b4 | Rust | rolo/midigrep | /src/main.rs | UTF-8 | 3,104 | 2.609375 | 3 | [] | no_license | extern crate nom_midi as midi;
extern crate nom;
extern crate walkdir;
extern crate rayon;
extern crate docopt;
extern crate colored;
#[macro_use] extern crate serde_derive;
use std::process;
use std::path::PathBuf;
use std::env;
use docopt::Docopt;
use rayon::prelude::*;
use walkdir::WalkDir;
mod midifind;
mod str_... | true |
98dcffd5957dab4439eb49d02abe09e368f3ecc3 | Rust | weworld/rusty-leetcode | /src/string_tag/palindrome_permutation_266.rs | UTF-8 | 1,036 | 3.078125 | 3 | [
"WTFPL"
] | permissive | /*
* @lc app=leetcode.cn id=266 lang=rust
*
* [266] 回文排列
*/
// @lc code=start
use std::collections::HashMap;
impl Solution {
pub fn can_permute_palindrome(s: String) -> bool {
let mut dict = HashMap::<char, usize>::new();
for c in s.chars() {
dict.entry(c)
.and_modi... | true |
f25b49b360a1969155ba822622072e00ec2f1058 | Rust | ritobanrc/aoc2020 | /src/day03.rs | UTF-8 | 1,459 | 3.375 | 3 | [
"MIT"
] | permissive | use euclid::{vec2, Point2D};
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
enum Square {
Open,
Tree,
}
fn parse_input(input: String) -> Vec<Vec<Square>> {
input
.lines()
.map(|line| {
line.trim()
.chars()
.map(|c| match c {
'.'... | true |
c6321528a65522c3da97ae7f4d414b78854ed665 | Rust | icub3d/puzzles | /leetcode/projection-area-of-3d-shapes/src/lib.rs | UTF-8 | 1,009 | 3.28125 | 3 | [
"MIT"
] | permissive | pub struct Solution;
impl Solution {
pub fn projection_area(grid: Vec<Vec<i32>>) -> i32 {
let mut result = 0;
let mut max_row = vec![0; grid.len()];
let mut max_col = vec![0; grid[0].len()];
for i in 0..grid.len() {
for j in 0..grid[0].len() {
if grid[i][... | true |
3b002a52236949a4e1d7ded35ded903c1cab2993 | Rust | gauteh/dars | /dars-catalog/src/handlers.rs | UTF-8 | 2,748 | 2.828125 | 3 | [
"MIT"
] | permissive | use crate::Catalog;
use serde::Serialize;
use std::sync::Arc;
use tera::Tera;
use warp::hyper::Body;
use warp::Reply;
#[derive(Serialize)]
struct Element {
path: String,
display: String,
}
pub async fn index<T: Catalog + Clone>(
root: String,
tera: Arc<Tera>,
catalog: T,
) -> Result<impl warp::Rep... | true |
517fb91a6f53495b365c1679f91590115e87d51a | Rust | BafDyce/adventofcode | /2015/rust/18/part1_optimized.rs | UTF-8 | 3,850 | 3.3125 | 3 | [
"Unlicense"
] | permissive | // adventofcode - day 18
// part 1 - optimized
//
// the optimized variants use two grids with a ring of lights (set to off)
// around the real grid. This brings two optimizations:
// 1) the ring around the grid:
// no check which iterators are needed is required -> a little bit of time
// saved.
// 2) we use... | true |
70fc4ee4b7ece4d071381f5f9e52cb30f6bd985a | Rust | kaj/rsass | /rsass/tests/spec/core_functions/meta/calc_name.rs | UTF-8 | 2,894 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Tests auto-converted from "sass-spec/spec/core_functions/meta/calc_name.hrx"
#[allow(unused)]
fn runner() -> crate::TestRunner {
super::runner().with_cwd("calc_name")
}
#[test]
fn calc() {
assert_eq!(
runner().ok("@use \"sass:meta\";\
\na {b: meta.calc-name(calc(var(--c)))}\n"),
... | true |
ff7e061cae18e2c60f928ba375a1bf330478ab90 | Rust | markhildreth/space-trouble | /src/controls/four_switch.rs | UTF-8 | 1,113 | 3.078125 | 3 | [] | no_license | use super::{Control, Pin, PinValue};
use st_core::common::*;
pub struct FourSwitch<P1, P2, P3>
where
P1: Pin,
P2: Pin,
P3: Pin,
{
pin_one: P1,
pin_two: P2,
pin_three: P3,
}
impl<P1, P2, P3> FourSwitch<P1, P2, P3>
where
P1: Pin,
P2: Pin,
P3: Pin,
{
pub fn new(pin_one: P1, pin_tw... | true |
8646d75f75b0c72224cad0c756c01e499a30dfd9 | Rust | michelhe/rustboyadvance-ng | /arm7tdmi/src/arm/mod.rs | UTF-8 | 18,942 | 2.8125 | 3 | [
"MIT"
] | permissive | #[cfg(feature = "debugger")]
pub mod disass;
pub mod exec;
use serde::{Deserialize, Serialize};
use super::alu::*;
use super::memory::Addr;
use super::InstructionDecoder;
use bit::BitIndex;
use byteorder::{LittleEndian, ReadBytesExt};
use num::FromPrimitive;
use std::io;
#[derive(Debug, PartialEq, Eq)]
pub enum Ar... | true |
3285c2b983b3c050022549135e3fa7d21e1bfbd4 | Rust | isgasho/velcro | /core/src/hash_set.rs | UTF-8 | 1,723 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::seq::SeqInput;
use crate::value::{Value, ValueExpr, ValueIterExpr, Verbatim};
use proc_macro2::{Ident, Span, TokenStream};
use quote::{quote, ToTokens};
use syn::parse::{self, Parse, ParseStream};
pub struct HashSetInput<V = Verbatim>(SeqInput<V>);
impl<V> Parse for HashSetInput<V>
where
Value<V>: Pars... | true |
b65ecd6c13d0d6ab57e2afe46bd0142ceddb4128 | Rust | jsperafico/learn-rust | /9.3_panic_or_not/src/guess.rs | UTF-8 | 310 | 3.484375 | 3 | [
"MIT"
] | permissive | pub struct Guess {
value : u32
}
impl Guess {
pub fn new(value : u32) -> Guess {
if value < 1 || value > 100 {
panic!("Guess value should be between 1 and 100, and got {}", value);
}
Guess { value }
}
pub fn value(&self) -> u32 {
self.value
}
} | true |
59454e9810830940c3e0eda74144410d15bf0d02 | Rust | dashed/se-challenge-expenses | /backend/response.rs | UTF-8 | 12,687 | 2.53125 | 3 | [] | no_license | // rust imports
use std::io::Read;
use std::ffi::OsStr;
use std::path::{PathBuf, Path};
use std::fs::{self, File};
use std::collections::HashMap;
// 3rd-party imports
use rusqlite::Connection;
use rusqlite::types::ToSql;
use hyper::http::h1::HttpReader;
use hyper::buffer::BufReader;
use hyper::net::NetworkStream;
u... | true |
fa51c435df4db8477fa5c4bad3afaec4ca5d818c | Rust | DenialAdams/glicko2 | /src/lib.rs | UTF-8 | 14,609 | 3.390625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![deny(missing_docs)]
//! An implementation of the [glicko2 rating system](http://www.glicko.net/glicko/glicko2.pdf). It's a rating system appropriate for rating a team or player and is leveraged by many chess leagues.
//!
//! To use, create a series of [`GameResult`](struct.GameResult.html) for each team or player i... | true |
029643f86cc669009516ad0a24023fe6eee653be | Rust | dhedegaard/adventofcode2018 | /src/day14/mod.rs | UTF-8 | 2,336 | 3.453125 | 3 | [] | no_license | pub fn get_input() -> usize {
704_321
}
pub fn part1(input: usize) -> String {
let mut recipes = vec![3, 7];
let mut elf1 = 0;
let mut elf2 = 1;
while recipes.len() < input + 10 {
let total = recipes[elf1] + recipes[elf2];
if total >= 10 {
recipes.push(total / 10);
... | true |
4af5f3bc4170c2d15500c46e54ceb29b8575371f | Rust | OriginCode/aurchecker-rs | /src/network.rs | UTF-8 | 2,747 | 2.59375 | 3 | [] | no_license | use crate::parser;
use crate::{info, warn};
use anyhow::Result;
use console::style;
use git2::Repository;
use serde::Deserialize;
use alpm::Version;
use std::{
collections::{HashMap, HashSet},
path::Path,
process::{Command, Stdio},
};
const AUR_RPC_URL: &str = "https://aur.archlinux.org/rpc/?v=5&type=info&... | true |
ef58a0104fa28904cfa58e616bb9b163a873fc70 | Rust | ryanpbrewster/rust-project-euler | /src/problems/problem_005.rs | UTF-8 | 207 | 2.765625 | 3 | [] | no_license | extern crate num;
#[test]
fn small() {
assert_eq!(solve(10), 2520);
}
#[test]
fn main() {
assert_eq!(solve(20), 232792560);
}
pub fn solve(n: u32) -> u32 {
(1..n).fold(1, num::integer::lcm)
}
| true |
a6872e32a1eccdc87b3e0d71cee110619effd597 | Rust | solidsnack/sonnenbrille | /src/net_crc8.rs | UTF-8 | 1,273 | 3.65625 | 4 | [] | no_license | use crate::crc8::*;
use crate::netendian::*;
/// Note that most polynomials don't produce a checksum of all ones even when
/// the value is all ones.
const CHECKSUM_SALT: u8 = 0xFF;
/// A convenience wrapper for handling checksums of fixed-length machine words
/// in network byte order.
pub struct NetCRC8(CRC8);
imp... | true |
363478f66486503872e22679206fc6d1e4a3e7c8 | Rust | bestouff/tui-rs | /examples/layout.rs | UTF-8 | 2,339 | 2.6875 | 3 | [
"MIT"
] | permissive | extern crate log;
extern crate stderrlog;
extern crate termion;
extern crate tui;
use std::io;
use std::thread;
use std::sync::mpsc;
use termion::event;
use termion::input::TermRead;
use tui::Terminal;
use tui::backend::MouseBackend;
use tui::widgets::{Block, Borders, Widget};
use tui::layout::{Direction, Group, Rec... | true |
405d1947307894cd66e88ce7e5e914c248826e24 | Rust | yangzhe1990/conflux-rust | /core/src/vm/return_data.rs | UTF-8 | 2,102 | 2.8125 | 3 | [
"GPL-3.0-only",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.0-or-later",
"GPL-3.0-or-later",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"LicenseRef-scancode-other-copyleft"
] | permissive | // Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | true |
ad718e26e34ebf10d050c05630852c7b6067fada | Rust | sinato/rcc2 | /src/main.rs | UTF-8 | 702 | 2.546875 | 3 | [] | no_license | extern crate inkwell;
extern crate rcc2;
use std::{env, process};
use rcc2::emitter::emitter::Emitter;
use rcc2::lexer::Lexer;
use rcc2::parser::parser;
fn compiler(code: String) {
// let input = String::from("1 * 2");
let lexer = Lexer::new();
let mut tokens = lexer.lex(code);
// dbg!(tokens.clone()... | true |
0a2a654791c0542d0ec199f577f6be18af37112f | Rust | cybear/advent-of-code-2020 | /day7/src/part2.rs | UTF-8 | 3,943 | 3.765625 | 4 | [] | no_license | struct Bag {
color: String,
contents: Vec<(usize, String)>,
}
impl std::fmt::Display for Bag {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "Bag color: {}, children: {:?}", self.color, self.contents)
}
}
pub fn calculate(s: &str) -> usize {
let parsed_lines = s... | true |
94378fffab998ef968df67cf77142b731b658d58 | Rust | HevanHull/Rust | /chapter3/sub3.2/chars/src/main.rs | UTF-8 | 145 | 2.71875 | 3 | [] | no_license | fn main() {
let z = 'J';
let y = 'E';
let a = 'L';
let hello = 'O';
println!("{}{}{}{}{}, world!", z , y, a ,a , hello);
}
| true |
ea6c25a4d8d6c3cd3ba27f1a27a4327e562c679b | Rust | raviqqe/ssf | /ssf/src/ir/algebraic_alternative.rs | UTF-8 | 1,958 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | use super::{constructor::Constructor, expression::Expression};
use crate::types::Type;
use std::collections::{HashMap, HashSet};
#[derive(Clone, Debug, PartialEq)]
pub struct AlgebraicAlternative {
constructor: Constructor,
element_names: Vec<String>,
expression: Expression,
}
impl AlgebraicAlternative {
... | true |
354670cbe37142ab1224adcf6afbd99cfb09c349 | Rust | mvertescher/fitbit-web-api-rs | /src/bin/fitbit-web-api/client/activity.rs | UTF-8 | 2,232 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | //! Client for the activity endpoints
use super::get;
use fitbit_web_api::*;
pub(crate) async fn get_goals() {
let url = activity::goals::url();
let body = get(url).await;
let response: activity::goals::Response = serde_json::from_str(&body).unwrap();
println!("{}", response);
}
pub(crate) async fn ... | true |
844f3182699d63207b5fc28be39918cda0afc9a3 | Rust | DreamLarva/learn-rust | /proc_marco/src/hex.rs | UTF-8 | 729 | 3.03125 | 3 | [] | no_license | use proc_macro::{Delimiter, Group, TokenStream, TokenTree};
use std::iter::FromIterator;
// 类函数宏
// 类函数宏定义看起来像函数调用的宏。
// 类似于 macro_rules!,它们比函数更灵活;
// 例如,可以接受未知数量的参数。
// 然而 macro_rules! 宏只能使用之前 “使用 macro_rules! 的声明宏用于通用元编程” 介绍的类匹配的语法定义。
// 类函数宏获取 TokenStream 参数,其定义使用 Rust 代码操纵 TokenStream,就像另两种过程宏一样。
#[proc_macro]
pub... | true |
fbe2dfca31fc573ae02ac1353cbdc6ee6b410fbe | Rust | mesonbuild/meson | /test cases/rust/9 unit tests/test.rs | UTF-8 | 370 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | pub fn add(a: i32, b: i32) -> i32 {
return a + b;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add() {
assert_eq!(add(1, 2), 3);
}
#[test]
fn test_add_intentional_fail() {
assert_eq!(add(1, 2), 5);
}
#[test]
#[ignore]
fn test_add_intentional_fa... | true |
2039a957c823c7f10cf0f342ab213140a971b584 | Rust | yvt/farcri-rs | /src/target/cortex_m_time.rs | UTF-8 | 1,692 | 2.6875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Temporal quantifier for Cortex-M devices
//!
//! This port uses SysTick for measurement. Unfortunately it's only a 24-bit
//! timer, so there will be some measurement errors roughly proportional to
//! the measured durations.
use core::sync::atomic::{AtomicUsize, Ordering};
use cortex_m::peripheral::{syst, SYST};
... | true |
c354632d2ace84a42bc6fe948a9bd7e390e9cd7c | Rust | steveklabnik/rust-atom | /src/person.rs | UTF-8 | 238 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | /// [The Atom Syndication Format § Person Constructs]
/// (https://tools.ietf.org/html/rfc4287#section-3.2)
#[derive(Clone,Default)]
pub struct Person {
pub name: String,
pub uri: Option<String>,
pub email: Option<String>,
}
| true |
2a7d5fa4eabebb5fd77374b7cd053273da6a36eb | Rust | magiclen/chinese-number | /src/chinese_to_number/naive.rs | UTF-8 | 9,627 | 3.328125 | 3 | [
"MIT"
] | permissive | #[cfg(not(feature = "std"))]
#[allow(unused_imports)]
use num_traits::float::FloatCore;
use super::to_chars_vec;
use crate::{
chinese_characters::{ChineseNumber, ChinesePoint, ChineseSign},
ChineseToNumberError,
};
fn chinese_to_unsigned_integer(chars: &[char]) -> Result<u128, ChineseToNumberError> {
let ... | true |
a8c54e581e757acc634dbc488cf120e39521b86d | Rust | saschagrunert/webapp.rs | /backend/tests/server.rs | UTF-8 | 5,133 | 2.78125 | 3 | [
"MIT"
] | permissive | use anyhow::{format_err, Result};
use lazy_static::lazy_static;
use reqwest::blocking::Client;
use serde_json::from_slice;
use std::{sync::Mutex, thread, time::Duration};
use url::Url;
use webapp::{
config::Config,
protocol::{model::Session, request, response},
API_URL_LOGIN_CREDENTIALS, API_URL_LOGIN_SESSI... | true |
0d6fdc8b788ddaaaa208a89fc76e13f6403775e8 | Rust | theduke/rust | /src/test/run-pass/mir_match_arm_guard.rs | UTF-8 | 836 | 2.828125 | 3 | [
"MIT",
"NCSA",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause",
"BSD-2-Clause",
"Unlicense",
"LicenseRef-scancode-other-permissive"
] | permissive | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | true |
1fae8fc2bfa7935b79b496034d25a1578bbf34eb | Rust | carlosb1/projects-rust | /bot_news/web_app/src/db/comment_repo.rs | UTF-8 | 2,922 | 2.84375 | 3 | [] | no_license | use crate::entities::Comment;
use futures::stream::StreamExt;
use mongodb::bson::doc;
use mongodb::bson::Array;
use mongodb::{options::ClientOptions, options::FindOptions, Client};
use rocket::request::{FromRequest, Outcome};
use rocket::Outcome::Success;
use rocket::Request;
use serde::{Deserialize, Serialize};
use st... | true |
93b5786eb713cfc26f23fbb4d32151983fcf18be | Rust | shaneutt/lumen | /examples/spawn-chain/src/elixir/chain/counter_2/label_3.rs | UTF-8 | 1,774 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | use std::convert::TryInto;
use std::sync::Arc;
use liblumen_alloc::erts::exception::Alloc;
use liblumen_alloc::erts::process::code::stack::frame::{Frame, Placement};
use liblumen_alloc::erts::process::{code, Process};
use liblumen_alloc::erts::term::prelude::*;
pub fn place_frame_with_arguments(
process: &Process... | true |
c40d51b0839179f3a6ea858368cb53cb53509eae | Rust | PicoJr/bswp-cli | /tests/integration.rs | UTF-8 | 2,956 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(test)]
mod tests {
use assert_cmd::Command;
use std::io::{Read, Write};
use tempfile::Builder;
#[test]
fn test_stdin_stdout_missing_pattern() {
let mut cmd = Command::cargo_bin("bswp-cli").unwrap();
cmd.write_stdin("AAAA").assert().failure();
}
#[test]
fn test_std... | true |
a2b54075c7240dd36d12a09cc9a0f555d6691afa | Rust | Allen-Ning/Algorithm-solutions | /rust/src/solution104.rs | UTF-8 | 1,063 | 3.28125 | 3 | [] | no_license | // Definition for a binary tree node.
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
pub fn new(val: i32) -> Self {
TreeNode {
val,
left: None,
right: None... | true |
3abda9fb931f6b64de1d98e5dd17165b0d588f32 | Rust | danieldk/dpar | /dpar/src/models/tensorflow/tensor.rs | UTF-8 | 3,242 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | use std::ops::{Deref, DerefMut};
use enum_map::EnumMap;
use crate::features::Layer;
use tensorflow::{Tensor, TensorType};
/// Ad-hoc trait for shrinking batches.
pub trait ShrinkBatch {
fn shrink_batch(&self, n_instances: u64) -> Self;
}
impl<T> ShrinkBatch for Tensor<T>
where
T: Copy + TensorType,
{
fn... | true |
5efa86b3b3a609a5e236b41271b6c5ddb933393b | Rust | p2mate/aoc2020 | /day8/src/main.rs | UTF-8 | 4,232 | 3.25 | 3 | [
"Apache-2.0"
] | permissive | use std::{io::{self, BufRead, BufReader}, env::var};
use std::path::Path;
use std::str::FromStr;
use std::fmt::{self,Display};
#[derive(Debug, Clone)]
enum Opcode {
Nop(i32),
Jmp(i32),
Acc(i32),
}
#[derive(Debug, Clone)]
struct OpcodeParseErr;
impl FromStr for Opcode {
type Err = OpcodeParseErr;
... | true |
736443e7e85013dcee5a3be9fe6343f863d1430d | Rust | simon-whitehead/tetrs | /src/game/scenes/scene.rs | UTF-8 | 729 | 2.8125 | 3 | [
"MIT"
] | permissive | use piston_window::*;
use game::scenes::MenuResult;
use game::window::GameWindow;
pub trait Scene {
fn process(&mut self, e: &Event) -> SceneResult;
fn render(&mut self, window: &mut GameWindow, e: &Event);
}
pub enum SceneResult {
None,
MainMenu,
NewGame,
PauseGame,
ResumeGame,
GameO... | true |
b5a554bd69ebb0bc508c7b0861b4343e428dfbc9 | Rust | dantarian/adventofcode2019 | /src/day6.rs | UTF-8 | 7,732 | 3.125 | 3 | [] | no_license | use std::error::Error;
use std::path::PathBuf;
use std::fs::File;
use std::io::{BufRead, BufReader, Read};
use std::collections::{HashMap, VecDeque};
pub fn run(filename: &PathBuf, part2: &bool) -> Result<(), Box<dyn Error>> {
let vec = read(File::open(filename)?)?;
let pairs = extract_pairs(vec)?;
let tre... | true |
a159c2083213be831cfe94e5460314e9222c079d | Rust | jxs/follower-maze.rs | /src/lib/events/streamer.rs | UTF-8 | 4,202 | 3.234375 | 3 | [] | no_license | use anyhow::Error;
use bytes::BytesMut;
use futures::StreamExt;
use log::debug;
use std::collections::HashMap;
use std::default::Default;
use std::io::{Error as IoError, ErrorKind};
use std::string::ToString;
use tokio::net::TcpListener;
use tokio::sync::mpsc::Sender;
use tokio_util::codec::{Decoder, FramedRead, LinesC... | true |
eba38cbe430deb1a71bc5290cca3ed130c0b2e8f | Rust | aspin/automagical | /src/projectile.rs | UTF-8 | 917 | 2.765625 | 3 | [] | no_license | use crate::data;
use bevy::prelude::*;
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
pub enum ProjectileType {
Arrow,
}
#[derive(Clone)]
pub struct Projectile {
pub damage: i32,
pub ttl: f32,
pub piercing: bool,
pub speed: f32,
}
impl Projectile {
pub fn new(damage: i32, ttl: f32, piercing: boo... | true |
f175528a2bc0684181288533a610d027edd122c0 | Rust | fbegyn/AoC2018 | /day01/src/main.rs | UTF-8 | 992 | 3.171875 | 3 | [
"Unlicense"
] | permissive | use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
let file = File::open("input.txt").expect("Failed to open file");
let mut _numbers: Vec<i32> = vec![];
for line in BufReader::new(file).lines() {
_numbers.push(
line.expect("Failed to read ... | true |
220073da0760f31d1ed54287c4c83f77f7226d2b | Rust | comradeHsu/lark | /src/instructions/math/sub.rs | UTF-8 | 2,457 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use crate::instructions::base::bytecode_reader::BytecodeReader;
use crate::instructions::base::instruction::{Instruction, NoOperandsInstruction};
use crate::runtime::frame::Frame;
///d_div
pub struct DSub(NoOperandsInstruction);
impl DSub {
#[inline]
pub const fn new() -> DSub {
return DSub(NoOperands... | true |
1d134072cacb0edd9cfd74cc64f736dbd329fceb | Rust | sampersand/sojourn | /sjvm/src/register/release.rs | UTF-8 | 2,089 | 3.234375 | 3 | [] | no_license | use crate::Word;
use super::RegisterTrait;
/// A release-mode register within [Sojourn's VM](crate::SojournVm).
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct Register(Word);
impl RegisterTrait for Register {
#[inline(always)]
fn new(word: Word) -> Self ... | true |
7271b16dff67e604e0b419f09cc03e3e816f21b6 | Rust | yutiansut/actix-server-alt | /actix-service-alt/src/service/mod.rs | UTF-8 | 4,227 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use core::{
future::Future,
ops::Deref,
pin::Pin,
task::{Context, Poll},
};
use alloc::{boxed::Box, rc::Rc, sync::Arc};
pub(crate) mod then;
pub trait Service<Req> {
type Response;
type Error;
type Future<'f>: Future<Output = Result<Self::Response, Self::Error>>;
fn poll_ready(&sel... | true |
bba3183898e7a702323998435e75810dadee93a7 | Rust | CyberSys/WADparser-ogre | /src/parser/texture/font.rs | UTF-8 | 1,472 | 2.703125 | 3 | [
"MIT"
] | permissive | use nom::IResult;
use crate::{
repr::texture::{RowData, Texture, TextureFont},
parser::parse_image,
};
use nom::{
multi::fill,
number::complete::{le_u16, le_u32},
sequence::tuple,
};
use crate::repr::texture::CharData;
use super::parse_texture_size;
/// Parse a [`RowData`] from a byte slice.
pu... | true |
76a99eae317345132b92b1090bf71c9b5f23b3b1 | Rust | nwiizo/workspace_2018 | /rust/coreutils/src/hostname/hostname.rs | UTF-8 | 5,271 | 2.75 | 3 | [
"MIT"
] | permissive | #![crate_name = "uu_hostname"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Alan Andrade <alan.andradec@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Synced with:
*
* https://www.opensource.appl... | true |
9102541f192387fec28596e87b9d6be8d2b80edf | Rust | varu3dbox/rust-sandbox | /algorithm_and_data_structure/chap02/src/bin/code_2_3.rs | UTF-8 | 240 | 2.796875 | 3 | [] | no_license | fn main() {
let mut N = String::new();
std::io::stdin().read_line(&mut N).ok();
let max_num = N.trim().parse().ok().unwrap();
let mut num = 2;
while num < max_num {
println!("{}", num);
num += 2;
}
} | true |
2f55007312f531657214cdd82e16798123a7c73d | Rust | livioribeiro/dbf-dextractor | /src/error.rs | UTF-8 | 4,757 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::error::Error as StdError;
use std::fmt;
use std::io::Error as IoError;
use serde::export::Formatter;
use crate::dbf::FieldType;
#[derive(Debug)]
pub struct UnsupportedFieldTypeError(pub char);
impl fmt::Display for UnsupportedFieldTypeError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Erro... | true |
bde54e876eab3e0f38c4439e4722910b17153594 | Rust | AndreasDahl/RustTraining | /knn/src/lib.rs | UTF-8 | 7,047 | 3.21875 | 3 | [] | no_license | use std::cmp::Ordering::Greater;
use std::collections::HashMap;
use std::io::prelude::*;
use std::io;
use std::io::BufReader;
use std::fs::File;
use std::fmt;
pub trait HasDistance {
fn distance(&self, &Self) -> f32;
}
#[derive(Clone, PartialEq, Debug)]
pub struct Point {
pub x: f32,
pub y: f32,
}
impl f... | true |
4d70c1fb096ade6a50a61228a37e96e7b76957f0 | Rust | fatcat2/rusty-salary | /src/main.rs | UTF-8 | 1,627 | 2.875 | 3 | [] | no_license | extern crate rusqlite;
use rusqlite::NO_PARAMS;
use rusqlite::{Connection, Result};
use actix_web::{get, web, App, HttpServer, Responder, HttpResponse};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
struct Salary {
last_name: String,
first_name: String,
middle_name: Strin... | true |
a189812392d226f052911601d5aa5c47b7bc36b0 | Rust | tuzz/laika | /src/util/direction/mod.rs | UTF-8 | 709 | 3.546875 | 4 | [] | no_license | use std::ops::{Add,Sub};
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Direction {
degrees: f32,
}
impl Direction {
pub fn new(degrees: f32) -> Self {
Self { degrees: Self::normalize(degrees) }
}
fn normalize(degrees: f32) -> f32 {
let m = degrees % 360.0;
if m < 0.0 {
... | true |
568116cdd9ac297bb6f0f5efa74f1db520958f93 | Rust | jeffparsons/grit-rs | /git-packetline/src/read/mod.rs | UTF-8 | 4,513 | 3.15625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[cfg(any(feature = "blocking-io", feature = "async-io"))]
use crate::MAX_LINE_LEN;
use crate::{PacketLine, U16_HEX_BYTES};
#[cfg(any(feature = "blocking-io", feature = "async-io"))]
type ExhaustiveOutcome<'a> = (
bool, // is_done
Option<PacketLi... | true |
47412f8b3a1b1b6b4a12258e91de9a5e6a504ffa | Rust | KoxSosen/RustLearning | /src/tuples.rs | UTF-8 | 390 | 3.96875 | 4 | [] | no_license | // Tuples - Interesting data type. Haven't used tuples at all before.
// It groups together values of different types. !! Max 12 elements !!
pub fn run() {
// This is a tuple.
let person: (&str, &str, i8) = ("Brad", "Mass", 37);
// Calling tuples
println!("{} - First tuple part, {} - is second value,... | true |
90d40c26f43b7614f147f1c3ea147332fe6c1b29 | Rust | insinfo/termscp | /src/filetransfer/transfer/s3/object.rs | UTF-8 | 8,270 | 2.859375 | 3 | [
"MIT"
] | permissive | //! ## S3 object
//!
//! This module exposes the S3Object structure, which is an intermediate structure to work with
//! S3 objects. Easy to be converted into a FsEntry.
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining ... | true |
0124422717cef0377579e1d5fe7daa9946c1b675 | Rust | zesterer/fuckvm | /src/ir/hir.rs | UTF-8 | 4,484 | 3.125 | 3 | [
"WTFPL"
] | permissive | use std::collections::HashMap;
use super::{
lir,
Type,
Value,
OpKind,
};
use crate::Error;
#[derive(Debug)]
pub struct Program {
pub(crate) funcs: HashMap<String, Function>,
}
#[derive(Debug)]
pub struct Function {
pub(crate) output: Type,
pub(crate) input: (String, Type),
pub(crate) b... | true |
7b6527c75bb9e17f4bf2ccdb6974a22bb7d258cf | Rust | ehuss/cargo-dep | /src/main.rs | UTF-8 | 7,726 | 2.640625 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate clap;
extern crate cargo_metadata;
#[macro_use]
extern crate failure;
extern crate semver;
use cargo_metadata::DependencyKind;
use clap::{App, Arg, ArgMatches};
use failure::{Error, ResultExt, SyncFailure};
use std::collections::{HashMap, HashSet};
use std::path::Path;
use std::process::exit;... | true |
4ded755aab986dfab4b2fb48dda5d57cc2e23dda | Rust | kazpot/bitcoin-address-generator | /src/address/seed.rs | UTF-8 | 3,629 | 3.140625 | 3 | [] | no_license | use crate::crypto::aes::{decrypt, encrypt};
use crate::crypto::password_key::gen_key;
use rand::rngs::OsRng;
use rand::RngCore;
use rpassword::read_password;
use std::env::current_dir;
use std::fs;
use std::fs::{File};
use std::process;
use std::io::Write;
/// Seed size (256 bits is advised in BIP32)
const SEED_SIZE_... | true |
9b7b476d1e50c21e9c19d16052c391dd37ba69bd | Rust | apache/incubator-teaclave-sgx-sdk | /sgx_tstd/src/sys/backtrace/mod.rs | UTF-8 | 6,840 | 2.734375 | 3 | [
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
bc4f2090227208c68ed1f8b07e9b18fa2cb7f499 | Rust | connormai/image-server-rust | /src/util.rs | UTF-8 | 285 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::io;
use std::io::Read;
pub fn read_whole<T: ?Sized + Read>(readable: &mut T) -> io::Result<Vec<u8>> {
let mut buffer = Vec::<u8>::new();
let result = readable.read_to_end(&mut buffer);
match result {
Ok(_) => Ok(buffer),
Err(e) => Err(e)
}
}
| true |
a16a84248fcd7d4ef24ebe161a021703311136a0 | Rust | fhools/aoc2015 | /day12/src/main.rs | UTF-8 | 1,435 | 3.4375 | 3 | [] | no_license | use serde_json::Value;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
const PART: u8 = 2;
fn sum_nums(val: &Value) -> f64 {
let mut sum = 0.0;
match val {
Value::Object(ref map) => {
let mut foundred = false;
// Part 2 skips counting any objects (and chidre... | true |
5a23d98cb21c223e8e1dac2fefae0a39453073e4 | Rust | MDGSF/JustCoding | /rust-leetcode/leetcode_2427/src/solution1.rs | UTF-8 | 521 | 3.515625 | 4 | [
"MIT"
] | permissive | impl Solution {
pub fn common_factors(a: i32, b: i32) -> i32 {
let mut count = 0;
for i in 1..=(a.max(b)) {
if a % i == 0 && b % i == 0 {
count += 1;
}
}
count
}
}
pub struct Solution;
#[cfg(test)]
mod tests {
use super::*;
#[tes... | true |
e375f967897616736357da36b9770aaaa927d7b0 | Rust | FelixMcFelix/rs2 | /rs2_macro/src/lib.rs | UTF-8 | 6,729 | 2.859375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate proc_macro;
use quote::*;
use syn::{parse_macro_input, Expr, ExprArray, Ident};
/// Convert a list of OpCode definitions (R, I, J type) into varying
/// parts of associated machinery.
///
/// Defining an instruction as `(NAME, fn, op, delay)`,
/// this takes 2 parameters:
/// * Switched instructions, a l... | true |
04bb9473cf4c1f09347327bbdf16ba05f3e52fed | Rust | jzrake/hydro-rs | /lib-config/src/lib.rs | UTF-8 | 5,711 | 3.546875 | 4 | [] | no_license | use std::collections::HashMap;
use std::fmt;
// ============================================================================
#[derive(Clone)]
pub enum Value {
B(bool),
I(i64),
F(f64),
S(String),
}
impl From<bool> for Value { fn from(a: bool) -> Self { Value::B(a) } }
impl From<i64> for Value { fn ... | true |
4ff14eb9356ed609c13c81336f95a4f1e0d952c5 | Rust | Viphor/POOP | /src/type_system/mod.rs | UTF-8 | 5,123 | 3.4375 | 3 | [] | no_license | use crate::parser::ast::*;
mod error;
pub type Output<Out = ()> = Result<Out, error::TypeSystemError>;
pub struct TypeSystem {}
impl TypeSystem {
pub fn analyze(_ast: &Program) {
unimplemented!();
}
fn statement(&mut self, _statement: &Statement) -> Output<Type> {
unimplemented!();
... | true |
dc6c6bd553fbdad4f5e3e56a7e09cf532c3f9870 | Rust | termoshtt/cagra | /cagra/src/error.rs | UTF-8 | 1,185 | 2.921875 | 3 | [
"MIT"
] | permissive | use failure::Fail;
pub type Result<T> = ::std::result::Result<T, Error>;
#[derive(Fail, Debug)]
pub enum Error {
/// value node is not initialized
#[fail(display = "Value node is not initialized (Index = {})", index)]
ValueUninitialized { index: usize },
/// derivative is not initialized
#[fail(di... | true |
8e23b20dab5d4f4f712f301ab3f53293903763b2 | Rust | tpickett66/cryptopals-rs | /examples/ecb_cut_and_paste.rs | UTF-8 | 1,571 | 2.6875 | 3 | [] | no_license | //extern crate crypto;
extern crate crypto_challenges;
use crypto_challenges::{padded_ecb_encrypt, aes_ecb_decrypt};
use crypto_challenges::query_string;
const KEY: &'static [u8] = b"Ice Ice baby!!1!";
fn main() {
let first_profile = query_string::profile_for("1337pwner@pwners.com");
let second_profile = que... | true |
f0b96f1d0ce4ca70ea35f8507033a00a6a46b5e2 | Rust | Eraden/rider | /rider-generator/src/themes.rs | UTF-8 | 2,551 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::*;
use rider_themes::predef::*;
use rider_themes::Theme;
use std::fs;
use std::path::PathBuf;
pub fn create(directories: &Directories) -> std::io::Result<()> {
fs::create_dir_all(directories.themes_dir.clone())?;
for theme in default_styles() {
write_theme(&theme, directories)?;
}
Ok... | true |
361eec5f9ffce9ddfd00d4b04c866b57821f3051 | Rust | authereum/zksync | /core/storage/src/tokens/mod.rs | UTF-8 | 3,577 | 2.84375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Built-in deps
use std::collections::HashMap;
// External imports
use diesel::prelude::*;
// Workspace imports
use models::node::{Token, TokenId, TokenLike, TokenPrice};
// Local imports
use self::records::{DbTickerPrice, DbToken};
use crate::schema::*;
use crate::tokens::utils::address_to_stored_string;
use crate::S... | true |
70dd671ef64b14c517a8ab231347edaea994ab87 | Rust | Mark-Simulacrum/unicode-reverse | /src/lib.rs | UTF-8 | 5,434 | 3.953125 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | #![no_std]
//! The [`reverse_grapheme_clusters_in_place`][0] function reverses a string slice in-place without
//! allocating any memory on the heap. It correctly handles multi-byte UTF-8 sequences and
//! grapheme clusters, including combining marks and astral characters such as Emoji.
//!
//! ## Example
//!
//! ```... | true |
1b8d83fcab6ff8650e1846020f2c4772116eccd0 | Rust | Stephen-J/codewars | /rust/6kyu/good_vs_evil.rs | UTF-8 | 1,393 | 3.28125 | 3 | [] | no_license | // https://www.codewars.com/kata/52761ee4cffbc69732000738
fn good_vs_evil(good: &str, evil: &str) -> String {
let good_points : Vec<u32> = vec![1,2,3,3,4,10];
let evil_points : Vec<u32> = vec![1,2,2,2,3,5,10];
let good_wins : String = String::from("Battle Result: Good triumphs over Evil");
let evil_wi... | true |
8595e756afcdfdac25c8bb01c5e42c0a4b39be8d | Rust | fredyw/leetcode | /src/main/rust/src/bin/problem2765.rs | UTF-8 | 1,117 | 3.453125 | 3 | [
"MIT"
] | permissive | // https://leetcode.com/problems/longest-alternating-subarray/
pub fn alternating_subarray(nums: Vec<i32>) -> i32 {
let mut answer = 0;
let mut i = 0;
let mut found = false;
let mut is_one = true;
let mut length = 1;
while i < nums.len() - 1 {
if is_one && nums[i + 1] - nums[i] == 1 {
... | true |
490a3510ff6a23cea9fada2614892ced17438d42 | Rust | a-dma/yubotp | /src/settings.rs | UTF-8 | 3,320 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use config::{Config, ConfigError, Environment, File};
use serde_derive::Deserialize;
use std::fmt;
#[derive(Debug, Deserialize, Clone)]
pub struct Server {
pub address: String,
pub port: u32,
}
impl fmt::Display for Server {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Serve... | true |
81fdaa9f661fc29e3ca9dcf3071dd7f3b32a4469 | Rust | qinxiaoguang/rs-lc | /src/solution/j2_054.rs | UTF-8 | 720 | 2.734375 | 3 | [] | no_license | use super::*;
use std::cell::RefCell;
use std::rc::Rc;
impl Solution {
// 倒序的中序遍历
pub fn convert_bst(root: Option<Rc<RefCell<TreeNode>>>) -> Option<Rc<RefCell<TreeNode>>> {
Self::_convert_bst(root.clone(), &mut 0);
return root;
}
fn _convert_bst(root: Option<Rc<RefCell<TreeNode>>>, sum:... | true |
b67a0f5106ec3b36c7579dd1c114d02b2e20c308 | Rust | coreos/bootupd | /src/model_legacy.rs | UTF-8 | 3,290 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright (C) 2020 Red Hat, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
//! Implementation of the original bootupd data format, which is the same
//! as the current one except that the date is defined to be in UTC.
use crate::model::ContentMetadata as NewContentMetadata;
use crate::model::InstalledConten... | true |
cd7c6fd193cc2dfc1368f0eb346992dcd77e10e6 | Rust | IThawk/rust-project | /rust-master/src/test/run-pass/typeclasses-eq-example.rs | UTF-8 | 1,651 | 3.109375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | #![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![feature(box_syntax)]
// Example from lkuper's intern talk, August 2012.
use Color::{cyan, magenta, yellow, black};
use ColorTree::{leaf, branch};
trait Equal {
fn isEq(&self, a: &Self) -> bool;
}
#[derive(Clone, Copy)]
enum Color {... | true |
b3941b2c8b057ae03dfa78662a6ae95c2ac96f4c | Rust | dunrix/unixbar | /src/format/data.rs | UTF-8 | 3,268 | 3.234375 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | use std::collections::BTreeMap;
#[derive(Debug, Clone, Copy)]
pub enum MouseButton {
Left,
Middle,
Right,
ScrollUp,
ScrollDown,
ScrollLeft,
ScrollRight,
/// Button used to navigate backwards in browsers
NavBack,
/// Button used to navigate forwards in browsers
NavForward,
}
... | true |
ca7480e6cb4158b35206e86405f4abbb9f48d64b | Rust | nanne007/ckb-vm | /src/memory/sparse.rs | UTF-8 | 7,686 | 3.109375 | 3 | [
"MIT"
] | permissive | use super::super::{Error, Register, RISCV_MAX_MEMORY, RISCV_PAGESIZE};
use super::{round_page, Memory, Page};
use std::cmp::min;
use std::marker::PhantomData;
use std::ptr;
use std::rc::Rc;
const MAX_PAGES: usize = RISCV_MAX_MEMORY / RISCV_PAGESIZE;
const INVALID_PAGE_INDEX: u16 = 0xFFFF;
/// A sparse flat memory im... | true |
80985a1d6dee3995f4e47a1941f249cff661d556 | Rust | mm0205/aizu-rust | /src/itp1_6/a.rs | UTF-8 | 1,456 | 3.59375 | 4 | [] | no_license | //! ITP1_6_Aの回答
//! [https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_A](https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_A)
use std::io::BufRead;
#[allow(dead_code)]
pub fn main() {
loop {
if let Some(input) = read_input(std::io::stdin().lock()) {
let result = ... | true |
dc887730148206d93df5cefc80bce0c9f528b603 | Rust | songww/luwu | /src/processors/mod.rs | UTF-8 | 3,599 | 2.75 | 3 | [] | no_license | use std::fmt::Debug;
use serde::{Deserialize, Serialize};
use crate::models::transaction::{Transaction, TransactionBranch};
use crate::database::Conn;
use crate::errors;
mod tx_tcc_processor;
mod tx_saga_processor;
mod tx_xa_processor;
mod tx_message_processor;
pub use tx_xa_processor::TxXaProcessor;
pub use tx_tcc... | true |
2beb39dbbfb262b4555b82d08788598e79a5a55f | Rust | astleychen/standups_weekly | /src/main.rs | UTF-8 | 4,220 | 2.640625 | 3 | [] | no_license | extern crate chrono;
extern crate docopt;
extern crate hyper;
extern crate regex;
extern crate rustc_serialize;
use docopt::Docopt;
use regex::Regex;
use std::collections::HashMap;
mod api2;
mod bzapi;
#[cfg_attr(rustfmt, rustfmt_skip)]
const USAGE: &'static str = "
Standups Weekly Report.
Usage:
standups_weekly ... | true |
2dad34127c473d86ed947bf97ff6ee607a885e86 | Rust | myhendry/brad_rust | /src/others.rs | UTF-8 | 4,730 | 3.90625 | 4 | [] | no_license | #[allow(dead_code)]
use std::fs::File;
use std::io::prelude::*;
enum Direction {
Up,
Down,
Left,
Right,
}
// Struct
struct Color {
red: u8,
green: u8,
blue: u8,
}
// Tuple Struct
struct FavColor(u8, u8, u8);
// Struct with impl
struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
fn p... | true |
b1b6785298731b299829caf20521862d38cc5678 | Rust | AntonGepting/tmux-interface-rs | /src/commands/clients_and_sessions/new_session.rs | UTF-8 | 12,139 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use crate::commands::constants::*;
#[cfg(feature = "tmux_3_2")]
use crate::ClientFlags;
use crate::TmuxCommand;
use std::borrow::Cow;
/// Structure for creating a new session
///
/// # Manual
///
/// tmux 3.2:
/// ```text
/// new-session [-AdDEPX] [-c start-directory] [-e environment] [-f flags] [-F format]
/// [-n wi... | true |
2113261defa701e005e85810dd926c26c7cb6de1 | Rust | DC-Akita/akita | /src/database.rs | UTF-8 | 3,209 | 2.75 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::{convert::TryFrom, ops::Deref};
use url::Url;
cfg_if! {if #[cfg(feature = "akita-sqlite")]{
use crate::platform::sqlite::SqliteDatabase;
}}
cfg_if! {if #[cfg(feature = "akita-mysql")]{
use crate::platform::mysql::MysqlDatabase;
}}
use crate::{AkitaError, cfg_if, data::Rows, information::{DatabaseNa... | true |
0b3c28fe0b72967347358e26d313d6358fcc862e | Rust | furuhama/design_patterns_in_rust | /src/patterns/proxy.rs | UTF-8 | 1,482 | 3.5625 | 4 | [] | no_license | // Proxy pattern
pub fn proxy() {
let mut rs = RealSubject::new();
println!("Create RealSubject");
println!("{}", rs.get_something());
let mut p1 = Proxy::new();
println!("Create Proxy p1");
let mut p2 = Proxy::new();
println!("Create Proxy p2");
println!("Get value from Proxy p1: {}"... | true |
78d224a7f9c81dbfc112526201d68f44f37f8301 | Rust | BlueGhostAlt/advent-of-code-2020 | /src/day04.rs | UTF-8 | 2,879 | 3.328125 | 3 | [
"Unlicense"
] | permissive | use std::collections::{HashMap, HashSet};
fn parse(input: &str) -> impl Iterator<Item = HashMap<&str, &str>> {
input.split("\n\n").map(|passport| {
passport
.split_whitespace()
.filter_map(|key_value| {
let mut key_value = key_value.split(':');
let ke... | true |
fd8094562ed2c585d002c83386cbb9d5b9b05436 | Rust | LinAGKar/advent-of-code-2017-rust | /day3a/src/main.rs | UTF-8 | 599 | 2.984375 | 3 | [
"MIT"
] | permissive | use std::io;
fn main() {
let mut string = String::new();
io::stdin().read_line(&mut string).expect("Failed to read line");
let register: i64 = string.trim().parse().unwrap();
if register < 1 {
panic!("Register must be at least 1");
}
println!("{}", if register == 1 { 0 } else {
... | true |
c5b4ea660bcd3dde0fe598892f883087c4bda852 | Rust | robert-snakard/tetris | /src/app.rs | UTF-8 | 2,331 | 2.546875 | 3 | [] | no_license | use crate::events::*;
use std::cell::RefCell;
use std::sync::Arc;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::*;
const WIDTH: u32 = 100;
const HEIGHT: u32 = 200;
const HOOK_ID: &str = "tetris";
pub struct WebApp {
pub events: Arc<RefCell<EventQueue>>,
pub ctx: CanvasRenderingContext2d... | true |
b20f865077e27b59723ff4fab407fb7d76820f67 | Rust | 2lx/luafmt | /src/parser/lexer_util.rs | UTF-8 | 23,783 | 3.28125 | 3 | [
"MIT"
] | permissive | type TChars<'a> = std::iter::Peekable<std::iter::Enumerate<std::str::Chars<'a>>>;
fn seek_end_by_predicate(chars: &mut TChars, start: usize, f: &dyn Fn(char, bool) -> bool) -> (usize, bool, String) {
let mut result = String::new();
if chars.peek().is_none() {
return (start, false, result);
};
... | true |
d8b0390315d97a5170cbe71dc7777fc9e7ee6b05 | Rust | astral-sh/ruff | /crates/ruff/src/rules/flake8_builtins/rules/builtin_attribute_shadowing.rs | UTF-8 | 4,732 | 3.0625 | 3 | [
"BSD-3-Clause",
"0BSD",
"LicenseRef-scancode-free-unknown",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0"
] | permissive | use ruff_python_ast as ast;
use ruff_python_ast::{Arguments, Decorator};
use ruff_text_size::TextRange;
use ruff_diagnostics::Diagnostic;
use ruff_diagnostics::Violation;
use ruff_macros::{derive_message_formats, violation};
use ruff_python_semantic::SemanticModel;
use crate::checkers::ast::Checker;
use crate::rules:... | true |
7fd4c9e50d7acba355aa6fd8ae5c55ce959985d9 | Rust | ladycarbonfiber/AdventOfCode | /src/day4.rs | UTF-8 | 843 | 3.125 | 3 | [] | no_license | use std::collections::HashSet;
use common::read_input;
use common::Part;
pub fn solve(part:Part){
let input = read_input(4);
let mut count = 0;
for line in input.lines(){
let tokens:Vec<&str> = line.split_whitespace().collect();
let total = tokens.len();
let mut comp:HashSet<String> ... | true |
05cb0f97cd6b23ee855f7d024fde6c48ce1066ff | Rust | pasaran/teya | /src/parser_error.rs | UTF-8 | 1,011 | 3.171875 | 3 | [] | no_license | use std::fmt;
use crate::TokenKind;
pub struct ParserError {
pos: usize,
kind: ParserErrorKind,
}
impl ParserError {
pub fn new( pos: usize, kind: ParserErrorKind ) -> Self {
ParserError {
pos,
kind,
}
}
}
impl fmt::Debug for ParserError {
fn fmt( &self... | true |
2ede57bbae9aa10cae651eff301d500c4d367f1e | Rust | matijakevic/lordbornebot | /modules/shapes/src/lib.rs | UTF-8 | 4,475 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | extern crate env_logger;
#[macro_use]
extern crate log;
extern crate rusqlite;
#[macro_use]
extern crate lordbornebot_core;
mod data;
use data::*;
use lordbornebot_core::{Config, Message, Module};
use rusqlite::Connection;
use std::boxed::Box;
use std::collections::HashMap;
#[no_mangle]
pub extern "C" fn _create_mod... | true |
6569dff23d1d7364d975c477c95bf1c5ef3cc80a | Rust | arn-the-long-beard/old_seed_archive | /examples/custom_router/src/pages/register/mod.rs | UTF-8 | 6,426 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::models::user::User;
use crate::request::RequestState;
use seed::{prelude::*, *};
pub fn init(url: Url, model: &mut Model, orders: &mut impl Orders<Msg>) -> Model {
Model::default()
}
#[derive(Default)]
pub struct Model {
user: User,
request_state: RequestState<User>,
}
/// Action on register p... | true |
4afbdc6238602ccb38041cf0d4b20565f4edc6f1 | Rust | stevenroose/rust-bitcoin-p2p | /src/mio_io.rs | UTF-8 | 5,702 | 3.1875 | 3 | [
"CC0-1.0"
] | permissive |
use std::{io, thread};
use std::sync::{atomic, mpsc};
use mio;
pub const WAKE_TOKEN: mio::Token = mio::Token(0);
/// An error from calling the [WakerSender::send] method.
#[derive(Debug)]
pub enum WakerSenderError<T> {
/// An error sending on the sender.
Send(mpsc::SendError<T>),
/// An erro... | true |
4f584c4c7fb5d4438876a7de721a4806a0eb4f02 | Rust | imlyzh/SpicyCrab | /src/main.rs | UTF-8 | 3,606 | 2.578125 | 3 | [
"MIT"
] | permissive |
use std::collections::HashMap;
use tokio::prelude::*;
use tokio::net::{TcpStream, TcpListener};
use tokio::stream::StreamExt;
use pyo3::prelude::*;
use httparse::Request;
use url::Url;
use pyo3::types::{PyDict, IntoPyDict};
use std::iter::FromIterator;
type HeaderType = (Box<HashMap<String, Option<String>>>, Vec<(St... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.