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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
65a05445fe480a5bc9f4b36563d0818b1f9642e3 | Rust | kirinse/seed-bootstrap | /example/frontend/src/lib.rs | UTF-8 | 3,153 | 2.71875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | mod page;
use seed::prelude::*;
use std::borrow::Cow;
// ------ ------
// Init
// ------ ------
fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
orders.subscribe(Msg::UrlChanged);
Model {
page: Route::from_url(url).to_page(orders),
}
}
// ------ ------
// Model
// ------ ----... | true |
c37ee3d0f94684fa5859893b7849a98346417da5 | Rust | Nereuxofficial/rust_move_gen | /src/piece.rs | UTF-8 | 5,447 | 3.03125 | 3 | [
"MIT"
] | permissive | use side::Side;
use std::fmt;
pub type Internal = u8;
/// Represents a piece for a particular side (eg black knight)
#[derive(PartialEq, PartialOrd, Copy, Clone)]
pub struct Piece(Internal);
const CHARS: [char; 12] = ['B', 'b', 'Q', 'q', 'R', 'r', 'N', 'n', 'P', 'p', 'K', 'k'];
// const SYMBOLS: [char; 14] = ['♙', '... | true |
54b68fb9138a14804b98d27657ad45f85c12df27 | Rust | ia0/data-encoding | /lib/macro/src/lib.rs | UTF-8 | 7,813 | 3.421875 | 3 | [
"MIT"
] | permissive | //! Macros for data-encoding
//!
//! This library provides macros to define compile-time byte arrays from encoded strings (using
//! common bases like [base64], [base32], or [hexadecimal], and also custom bases). It also provides
//! a macro to define compile-time custom encodings to be used with the [data-encoding] cr... | true |
f440eefd0285927bdbec50afb5e4ba45d69bed66 | Rust | espdev/csaps-rs | /src/lib.rs | UTF-8 | 4,703 | 3.15625 | 3 | [
"MIT"
] | permissive | //! # Cubic spline approximation (smoothing)
//!
//! csaps is a crate for univariate, multivariate and n-dimensional grid data interpolation and approximation
//! using cubic smoothing splines.
//!
//! The crate provides functionality for computing and evaluating cubic smoothing splines.
//! It does not contain any spl... | true |
f03de2a9ca111aaada94596ce7410ddb68b3410a | Rust | AleksandarMitrevski/sudoku | /src/gui/logic/sudoku_board.rs | UTF-8 | 8,444 | 2.921875 | 3 | [] | no_license | use ::std::collections::HashSet;
use conrod::{self, widget, color, Colorable, Sizeable, Borderable, Positionable, Widget};
use ::game;
/// The type upon which we'll implement the `Widget` trait.
#[derive(WidgetCommon)]
pub struct SudokuBoard<'a> {
/// An object that handles some of the dirty work of rendering a GU... | true |
a93cae9afd186cdf54d7ad7be3788db2060a3b64 | Rust | drbh/preq-ngin | /src/bin/parse.rs | UTF-8 | 1,822 | 2.71875 | 3 | [] | no_license | extern crate regex;
use regex::Regex;
extern crate walkdir;
use scraper::{Html, Selector};
use std::error::Error;
use std::fs::File;
use std::io::Read;
use walkdir::WalkDir;
fn main() -> Result<(), Box<dyn Error>> {
let mut count = 0;
for entry in WalkDir::new("./pages/")
.follow_links(true)
.i... | true |
d3456c3aec9b4afd5f6449dbeaca1064fd30e373 | Rust | task-rs/task-rs | /crates/task-rs/src/components/task_list/mod.rs | UTF-8 | 1,510 | 2.6875 | 3 | [
"MIT"
] | permissive | use super::super::data::Status;
use super::{
task_status_filter::{self, Value::*},
Main, Refresh, TaskItem, TaskItemMessage,
};
use iced::*;
#[derive(Debug, Default, Clone)]
pub struct TaskList {
pub tasks: Vec<TaskItem>,
pub task_status_filter: task_status_filter::Value,
}
impl TaskList {
pub fn ... | true |
ab828716f9de0ce8e81fb4b9176af586b9662ebc | Rust | joephon/PoloDB | /src/polodb_bson/datetime.rs | UTF-8 | 709 | 3.1875 | 3 | [
"MIT"
] | permissive | use std::time::{SystemTime, UNIX_EPOCH};
#[derive(Debug, Clone)]
pub struct UTCDateTime {
timestamp: u64,
}
impl UTCDateTime {
pub fn new(timestamp: u64) -> UTCDateTime {
UTCDateTime {
timestamp,
}
}
pub fn now() -> UTCDateTime {
let start = SystemTime::now();
... | true |
de5f9445cdb2e1170856ea09563e1ad5192384a8 | Rust | myhilmyhill/tsrust | /src/ts/ts_packet.rs | UTF-8 | 2,670 | 2.75 | 3 | [] | no_license | #[cfg(test)]
mod tests;
use crate::rawbytes::RawBytes;
#[derive(Debug)]
pub struct TsPacket {
pub bytes: RawBytes<Vec<u8>>,
pub header: TsHeader,
pub adaptation: Option<TsAdaptationField>,
pub payload: Option<TsPayload>,
}
impl TsPacket {
pub fn try_new(buf: impl Into<Vec<u8>>) -> Option<Self> {
... | true |
5003aaf26cd3b27f264ae3eb5fa792570f62f25e | Rust | mh84/bastion | /src/tramp.rs | UTF-8 | 568 | 3.25 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | ///
/// Basic trampoline code for doing debouncing for supervision restarts.
///
pub enum Tramp<R> {
Traverse(R),
Complete(R),
}
///
/// Execution implementation for the debouncer
///
impl<R> Tramp<R> {
pub fn execute<F>(mut self, f: F) -> R
where
F: Fn(R) -> Tramp<R>,
{
loop {
... | true |
66e42e5dcdbc92d2bc9667e1b65ef02772ea4279 | Rust | keggsmurph21/k10 | /src/server/client.rs | UTF-8 | 1,098 | 2.546875 | 3 | [] | no_license | use mpsc::UnboundedSender;
use std::collections::HashMap;
use std::result::Result;
use std::sync::Arc;
use tokio::sync::{mpsc, RwLock};
use warp::ws::Message;
use warp::Error;
use super::model::game::GameId;
use super::model::user::{User, UserData, UserId};
use super::token::{new_token, Token};
#[derive(Clone, Debug,... | true |
0adaf1d20711f1f238dcea5a40599697a2c3581b | Rust | tonykuttai/Rust-Graph-Algorithms | /src/istree.rs | UTF-8 | 2,429 | 3.015625 | 3 | [] | no_license |
use std::path::Path;
use std::thread;
use std::sync::{Arc, Mutex};
static NTHREADS: usize = 4;
static mut CYCLE: bool = false;
static mut row_del: usize = 0;
fn is_tree(mut adj_list: &mut Vec< Vec<usize>>,mut visited: &mut Vec<bool>,nodes: usize){
unsafe{
let mut flag = false;
//let mut col: usize =... | true |
871a937ade400fb4f5945181877cac281806ea97 | Rust | DrkSephy/rust-sandbox | /src/types.rs | UTF-8 | 631 | 3.390625 | 3 | [] | no_license | /*
* Rust provides type safety using its static type checker. Variables can be
* type annotated when declared. However, the compiler can infer the type from
* the context, making annotation not mandatory.
*/
fn main(){
// Type annotated variable
let a_float: f64 = 1.0;
// This variable is an `int`
... | true |
24722aa43fb7653bde29b25863261077bcc11c6c | Rust | mhallin/socrates | /socrates-core/src/grounder.rs | UTF-8 | 12,135 | 2.65625 | 3 | [] | no_license | use std::rc::Rc;
use itertools::Itertools;
use socrates_ast::parsed::ActiveType;
use socrates_ast::parsed::{BinaryRelationOperator, IdentifierType, Quantifier};
use socrates_ast::simple::{Formula, Term};
use socrates_errors::eyre::Error;
use crate::cnf::CNFFormula;
use crate::cnf_receiver::CNFReceiver;
use crate::ga... | true |
5d29b54f20febba3eb12cece58ec8990782ae75d | Rust | renanaragao/estudando-rust | /src/ownership/src/main.rs | UTF-8 | 1,584 | 3.953125 | 4 | [] | no_license | fn main() {
ownership_function();
return_value_scope();
references_borrowing();
mutable_references();
slices();
}
fn ownership_function() {
let s = String::from("hello");
takes_ownership(s);
let x = 5;
makes_copy(x);
println!("x is {}", x);
}
fn takes_ownership(some_string:... | true |
4f4489eddff2743ed46d437dfd07ef6309a8f7a0 | Rust | rednim/blpapi-rs | /blpapi/tests/derive.rs | UTF-8 | 200 | 2.53125 | 3 | [
"MIT"
] | permissive | #![cfg(feature = "derive")]
use blpapi::RefData;
#[derive(Default, RefData)]
pub struct Equity {
pub crncy: String,
}
#[test]
fn derive_equity() {
assert_eq!(Equity::FIELDS, &["CRNCY"]);
}
| true |
afc5b3f607d75f34f111674320100a23efd2db35 | Rust | fossabot/sahke | /src/requests/payloads/set_chat_administrator_custom_title.rs | UTF-8 | 1,956 | 2.9375 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use crate::{
requests::{dynamic, json, Method},
types::{True, ChatId},
};
/// Use this method to set a custom title for an administrator in a supergroup
/// promoted by the bot.
#[serde_with_macros::skip_serializing_none]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deseria... | true |
85dba4cd0ff58c18895960e20963c9f5500c2d37 | Rust | bb010g/penny | /build.rs | UTF-8 | 6,594 | 2.640625 | 3 | [
"MIT"
] | permissive | extern crate phf_codegen;
extern crate quick_xml;
use std::collections::btree_map::{BTreeMap, Entry};
use std::env;
use std::fs::File;
use std::io::{BufRead, Write};
use std::path::Path;
use std::str;
use quick_xml::events::Event;
use quick_xml::reader::Reader;
#[derive(Debug)]
struct Currency {
code: String,
... | true |
d14c4ad4c8efe6bfd3b33f7367d537ebb48ba573 | Rust | tivek/exercism | /rust/sum-of-multiples/src/lib.rs | UTF-8 | 244 | 2.671875 | 3 | [] | no_license | extern crate itertools;
use itertools::Itertools;
pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 {
factors
.iter()
.map(|&i| (i..limit).step_by(i as usize))
.kmerge()
.dedup()
.sum()
}
| true |
655e68c9f9fa5fa0709ac7fb1d17ec6b55858bd2 | Rust | jonasvandervennet/advent-of-code-2020 | /src/day10.rs | UTF-8 | 4,034 | 3.40625 | 3 | [
"MIT"
] | permissive | use crate::util::{print_part_1, print_part_2};
use std::fs::read_to_string;
use std::time::Instant;
fn patch_cables(input: &Vec<usize>) -> usize {
let mut input = input.clone();
input.sort();
let mut diff_1 = 0;
let mut diff_3 = 1; // last connection is always a +3 connection
let mut prev = 0;
... | true |
febc8eff6cb07233f3a7872eafefaf7ceff34521 | Rust | or1426/rust-logic | /src/lval/ltype.rs | UTF-8 | 2,372 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::string;
use std::boxed;
use std::vec;
pub enum LType {
Bool,
List,
Array(boxed::Box<LType>),
Error,
Type,
Func((vec::Vec<LType>, boxed::Box<LType>)),
SpecialForm,
PlaceHolder,
Unknown,
}
impl Clone for LType{
fn clone(&self) -> LType{
match self {
&... | true |
2ea414e6481229c9979dcf3ada495345befc279b | Rust | RbertKo/follow-rust-book | /define_struct/src/main.rs | UTF-8 | 690 | 3.6875 | 4 | [] | no_license | struct User { // Struct
username: String,
email: String,
sign_in_count: u64,
active: bool,
}
struct Color(i32, i32, i32); // Tuple Struct
fn main() {
let mut user = get_user(String::from("MyeongSeok Ko"), String::from("myeongsku@gmail.com"));
user.active = false; // assign value to mutabl... | true |
efea85aa3d228521c3bf3df9af16569aedfcca7d | Rust | jhagans3/hands-on-data-structures-with-rust | /organizing-your-data-by-type-with-entity-component-systems/src/data.rs | UTF-8 | 222 | 2.734375 | 3 | [] | no_license | pub struct Strength {
pub strength: i16,
pub health: i16,
}
#[derive(PartialEq)]
pub struct Position {
pub x: i32,
pub y: i32,
}
pub struct Direction {
pub velocity_x: i32,
pub velocity_y: i32,
}
| true |
8469fe9c8c2a3e3981d3295aad1e00b5d62be66b | Rust | rAzoR8/rustest | /src/strahl/material.rs | UTF-8 | 6,510 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | use super::vec::*;
use super::ray::*;
use super::hit::*;
use super::random::*;
use super::texture::*;
#[derive(Copy, Clone)]
pub struct MaterialInfo
{
pub attenuation: Vec4,
pub emission: Vec4
}
impl MaterialInfo
{
pub fn new() -> MaterialInfo
{
MaterialInfo
{
attenuation: ... | true |
71d127a51065e0b9338b596c6096e9065ec11638 | Rust | onelson/destiny2-api-rs | /codegen/src/models/destiny_entities_vendors_destiny_vendor_category.rs | UTF-8 | 2,334 | 2.53125 | 3 | [] | no_license | /*
* Bungie.Net API
*
* These endpoints constitute the functionality exposed by Bungie.net, both for more traditional website functionality and for connectivity to Bungie video games and their related functionality.
*
* OpenAPI spec version: 2.0.0
* Contact: support@bungie.com
* Generated by: https://github.com... | true |
a4da033a66d75ed35d17e2a78b3676410d305ec4 | Rust | GeorgeKT/menhir-lang | /src/ast/function.rs | UTF-8 | 3,858 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::ast::{func_type, prefix, Expression, TreePrinter, Type};
use crate::span::Span;
#[derive(Debug, Eq, PartialEq, Clone, Hash, Serialize, Deserialize)]
pub struct Argument {
pub name: String,
pub typ: Type,
pub mutable: bool,
pub span: Span,
}
impl Argument {
pub fn new<S: Into<String>>(na... | true |
9e08ae1ef65fb6ffbf564d6e1b5307b8f337ffbd | Rust | dalalsunil1986/spinup | /libspinup/src/lib.rs | UTF-8 | 2,987 | 2.515625 | 3 | [
"MIT"
] | permissive | //! `libspinup` provides a common entry point for all functionality
//! used by the `spinup` binary.
//!
//! Currently, there is only one operation, which is to run the app. However
//! in the future this could change.
#[macro_use]
extern crate log;
#[macro_use]
extern crate lazy_static;
use flexi_logger::Logger;
pu... | true |
a73f9bff8f1c6ce867b458f23370124a404c2331 | Rust | UMD-CSSA/wxapp-server | /src/my_err.rs | UTF-8 | 735 | 2.8125 | 3 | [] | no_license | #![allow(dead_code)]
use std::fmt::{Debug, Formatter, Result};
pub(crate) const CONSOLE_FMT_WIDTH: usize = 50;
pub struct MyErr {
err: String,
file: &'static str,
line: u32,
}
impl MyErr {
pub fn from_str<T: Into<String>>(
str: T, file: &'static str, line: u32,
) -> Self {
Self { err: str.into(), ... | true |
369f5796f63fd441bf4db089db16d92ad92403b0 | Rust | Pomettini/impostor | /src/storage/mod.rs | UTF-8 | 1,711 | 2.9375 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::fs::OpenOptions;
use std::io::Read;
use std::io::Seek;
use std::io::SeekFrom;
use std::io::Write;
use std::path::Path;
use {Address, AddressBusBlockIO, As};
pub struct BlockDevice {
file: File,
pub block_size: usize,
max_size: u64,
}
impl BlockDevice {
pub fn new(mut file:... | true |
8b627bae93bc3012e8819edf436f18a578f21c5f | Rust | ANARCYPHER/Versus | /lambdas.rs | UTF-8 | 313 | 2.625 | 3 | [] | no_license | // code_report
//
fn main() {
let mut x = [ "bear", "cat", "elephant", "mouse" ];
let y = [ 1, 2, 3, 4, 5 ];
x.sort_unstable_by(|a, b| a.len().cmp(&b.len()));
println!("{:?}", x);
println!("{:?}", y.iter().fold(0, |a, b| a + b));
println!("{:?}", y.iter().fold(1, |a, b| a * b));
}
| true |
728691ea9bb54cbe4252f6d788bbcd73c6db7730 | Rust | caihui-1987/VSCode-Rust | /零散问题/生男孩女孩策略问题/src/main.rs | UTF-8 | 1,653 | 3.90625 | 4 | [] | no_license | //假定生男孩生女孩的比例是1:1,不能在孩子出生前选择孩子的性别,每队夫妻都希望至少有一个男孩,
//于是大家都采取这样一种生育策略,如果头胎是男孩,就不再生,如果头胎是女孩就生二胎,
//二胎是男孩就不生,是女孩就继续生,直到生出男孩为止,
//那么现在问,在这样一种策略下,整个社会是男孩多还是女孩多?
use rand::Rng;
fn main() {
let xiaohai = shengxiaohai(100);
println!("boy = {},girl = {}", xiaohai.boy, xiaohai.girl);
}
//定义一个结构体
struct Nannv {
boy: u3... | true |
e42e144fdf9a2108431bdd2bafb3a18c267689ec | Rust | Quang7hong81/btc-transaction-utils | /src/lib.rs | UTF-8 | 9,813 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // Copyright 2018 The Exonum Team
//
// 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 i... | true |
6e93b67960bc8666d21ec473c65f67111971dbb1 | Rust | llogiq/bytecount | /src/naive.rs | UTF-8 | 1,306 | 3.953125 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | /// Count up to `(2^32)-1` occurrences of a byte in a slice
/// of bytes, simple
///
/// # Example
///
/// ```
/// let s = b"This is yet another Text with spaces";
/// let number_of_spaces = bytecount::naive_count_32(s, b' ');
/// assert_eq!(number_of_spaces, 6);
/// ```
pub fn naive_count_32(haystack: &[u8], needle: u... | true |
5c56839606119a37584673040f35ebf35f4eccc2 | Rust | sunmeng90/rust-lang | /examples/list18-17/src/main.rs | UTF-8 | 4,674 | 3.921875 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | fn main() {
ignore_with__();
ignore_parts_of_a_value_with_nested__();
ignore_parts_of_a_tuple();
ignore_an_unused_variable_by_start_its_name_with__();
ignore_an_unused_variable_in_some_option_by_start_its_name_with_();
ignore_an_unused_variable__();
ignore_remaining_with_two_dots();
igno... | true |
105461c2ab34eac13f4f13cc47194bc78ea40255 | Rust | XuShaohua/nc | /src/calls/bind.rs | UTF-8 | 310 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | /// Bind a name to a socket.
pub unsafe fn bind(sockfd: i32, addr: &sockaddr_t, addrlen: socklen_t) -> Result<(), Errno> {
let sockfd = sockfd as usize;
let addr_ptr = addr as *const sockaddr_t as usize;
let addrlen = addrlen as usize;
syscall3(SYS_BIND, sockfd, addr_ptr, addrlen).map(drop)
}
| true |
4219c77d675e5efb9d8b7daaf72a7d2b5ebb9a26 | Rust | dcchut/aoc2019 | /src/questions/q3.rs | UTF-8 | 2,341 | 3.015625 | 3 | [] | no_license | use crate::grid::{Grid, HistoryVisitor, Position, StepVisitor};
use crate::{Extract, ProblemInput, Solution};
use std::collections::{HashMap, HashSet};
pub struct Q3;
impl Solution for Q3 {
fn part1(&self, lines: &ProblemInput) -> i64 {
let (path1, path2) = lines.extract().unwrap();
let grid1 = Gr... | true |
cfa0b35ed721152b303a668234058fb3a6f54320 | Rust | tarqd/unhtml.rs | /unhtml/src/test/from_html.rs | UTF-8 | 3,333 | 3.140625 | 3 | [
"MIT"
] | permissive | use crate::{
scraper::{Html, Selector},
ElemIter, Element, FromHtml, Result, Text,
};
#[derive(Debug, Eq, PartialEq)]
struct Link {
href: String,
text: String,
}
impl FromHtml for Link {
fn from_elements(select: ElemIter) -> Result<Self> {
let elements: Vec<_> = select.collect();
O... | true |
be3151fa65a21b6f006794602fc37041e5920d63 | Rust | kawamuray/phoseum | /src/album.rs | UTF-8 | 1,383 | 3.125 | 3 | [
"MIT"
] | permissive | use failure::Fail;
use std::fmt::Debug;
use std::iter::Iterator;
use std::path::Path;
use std::time::SystemTime;
pub trait Error: Fail {
/// Return if this error is caused by fatal error such as local hardware
/// glitch or misconfiguration that it is hopeless to keep running the app.
fn is_fatal(&self) ->... | true |
7a92241472f18e8f80f89a235b2e786323e2c31e | Rust | syllogy/hypergraph | /src/core/shared.rs | UTF-8 | 2,928 | 2.59375 | 3 | [
"MIT"
] | permissive | use crate::{errors::HypergraphError, HyperedgeIndex, Hypergraph, SharedTrait, VertexIndex};
use itertools::Itertools;
impl<V, HE> Hypergraph<V, HE>
where
V: SharedTrait,
HE: SharedTrait,
{
/// Private helper function used internally.
#[allow(clippy::type_complexity)]
pub(crate) fn get_connections(... | true |
cb38ac7d0a0c7806cb992eef0021192f578632be | Rust | realbigsean/lighthouse | /consensus/ssz/src/lib.rs | UTF-8 | 2,159 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | //! Provides encoding (serialization) and decoding (deserialization) in the SimpleSerialize (SSZ)
//! format designed for use in Ethereum 2.0.
//!
//! Adheres to the Ethereum 2.0 [SSZ
//! specification](https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/ssz/simple-serialize.md)
//! at v0.12.1.
//!
//! ## Example
//!... | true |
1412d19b4c14c5381de96217562afbbef886ee0f | Rust | libcala/cargo-cala | /window/src/input/keyboard/key.rs | UTF-8 | 5,021 | 3.03125 | 3 | [
"MIT"
] | permissive | // lib/input/keyboard/key.rs
// Graphical Software Packager
// Copyright 2017 (c) Aldaron's Tech
// Copyright 2017 (c) Jeron Lau
// Licensed under the MIT LICENSE
/// This enum represents a physical key on a keyboard.
#[derive(PartialEq, Eq)]
#[derive(Copy, Clone)]
pub enum Key {
// Note: These rows are not necessari... | true |
93a72954654800ccfda8b34317f6ed0b1b914bb3 | Rust | kralle333/chip8-rust | /src/mem.rs | UTF-8 | 1,364 | 3.421875 | 3 | [] | no_license | pub struct Memory {
ram: [u8; 4096],
}
const FONTS: [u8; 80] = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
0x90, 0x90, 0xF0, 0x10, 0x10, // 4
0xF0, 0x80, 0xF0, 0x10, 0xF0, // 5
0xF0, 0x80, 0... | true |
59dab0f962801aaadf67ce8f15a56027456d4d32 | Rust | zmilan/tinychain | /prototype/collection/btree/bounds.rs | UTF-8 | 5,717 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use std::cmp::Ordering;
use std::fmt;
use crate::collection::schema::Column;
use crate::error;
use crate::scalar::*;
use crate::{Match, TCResult, TryCastFrom, TryCastInto};
use super::collator::Collator;
use super::Key;
#[derive(Clone, Eq, PartialEq)]
pub struct BTreeRange(Vec<Bound>, Vec<Bound>);
impl BTreeRange {... | true |
6d3fbbd138123eb3ec9c5fdfb02efb8d01f20568 | Rust | Hirevo/rss-app | /api/src/routes/auth/logout.rs | UTF-8 | 683 | 2.609375 | 3 | [] | no_license | use diesel::prelude::*;
use tide::{Request, Response, StatusCode};
use crate::db::schema::*;
use crate::utils;
use crate::utils::auth::AuthExt;
use crate::State;
/// Route to log in to an account.
pub async fn post(req: Request<State>) -> tide::Result {
let token = match req.get_token() {
Some(token) => t... | true |
1d81a90967a1b26272a322f6737207221dc69d5c | Rust | Moxinilian/kira-demo | /src/ui/common/header.rs | UTF-8 | 806 | 2.875 | 3 | [
"MIT"
] | permissive | use std::marker::PhantomData;
use iced::{Align, Button, Row, Text};
use crate::ui::style::AppStyles;
pub struct Header<Message: Clone> {
back_button: iced::button::State,
back_button_message: Message,
text: String,
message: PhantomData<Message>,
}
impl<Message: Clone> Header<Message> {
pub fn new(text: String,... | true |
65365fc8507d8a28552d745601cbaa91e2c9f610 | Rust | SBentley/rust-book-examples | /traits/src/main.rs | UTF-8 | 1,286 | 3.484375 | 3 | [] | no_license | pub trait Summary {
fn summarize(&self) -> String {
format!("Read more from {}", self.summarize_author())
}
fn summarize_author(&self) -> String;
}
pub struct NewsArticle {
pub headline: String,
pub location: String,
pub author: String,
pub content: String,
}
impl Summary for ... | true |
2b38a9b52c08db274d50f82d23dfed65d05bc694 | Rust | lpc-rs/lpc-pac | /lpc11uxx/src/usart/fcr.rs | UTF-8 | 9,166 | 2.546875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[doc = "Register `FCR` writer"]
pub struct W(crate::W<FCR_SPEC>);
impl core::ops::Deref for W {
type Target = crate::W<FCR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::ops::DerefMut for W {
#[inline(always)]
fn deref_mut(&mut self) -> &mut Self::Tar... | true |
4cd432cb220a353f8e688b02b0a67b7185ccb7da | Rust | staktrace/datetimeutils | /src/lib.rs | UTF-8 | 10,205 | 3.734375 | 4 | [] | no_license | use std::fmt;
use std::time::{Duration, SystemTime, SystemTimeError};
/// Enum with the seven days of the week.
#[derive(Debug, Clone, Copy)]
pub enum Day {
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
}
/// Maps the `Day` enum to a string representation, e.g. "Monday".
... | true |
6d0db59bb2d7fb5cd287ee1ea099babbbaa44c11 | Rust | MSDimos/leetcode-rust2018 | /q108-convert-sorted-array-to-binary-search-tree/src/lib.rs | UTF-8 | 1,030 | 3.484375 | 3 | [
"MIT"
] | permissive | use leetcode_utils::TreeNode;
use std::cell::RefCell;
use std::rc::Rc;
pub struct Solution {}
impl Solution {
pub fn sorted_array_to_bst(nums: Vec<i32>) -> Option<Rc<RefCell<TreeNode>>> {
Solution::dichotomy(&nums[..])
}
fn dichotomy(nums: &[i32]) -> Option<Rc<RefCell<TreeNode>>> {
if num... | true |
1a9a5d83ab21e4766d6398a00a8510c7662de48d | Rust | albmar/pecunia | /src/market_values/percent.rs | UTF-8 | 507 | 2.90625 | 3 | [] | no_license | use std::fmt;
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, PartialOrd)]
pub struct Percent(pub(crate) f64);
impl_market_value!(impl Percent, one=0.01);
impl_market_value!(Percent, percent);
impl Percent {
pub const fn as_decimal(&self) -> f64 {
sel... | true |
0d0079e98b613c753073d27c22e459b0d95b8d4f | Rust | cginternals/yage | /yage-examples/src/texture/renderer.rs | UTF-8 | 4,152 | 2.75 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::f32::consts::PI;
use yage_core::{
glenum, cgmath, check_error,
Context, GlFunctions,
Cube, Transform, Camera,
Texture, TextureLoader,
BasicMeshRenderer,
GpuObject, Render, Update, Animation, MeshRenderer,
};
///
/// Example renderer that renders a single triangle.
///
pub struct Rende... | true |
60a29ab6252ee7d737666aa6968aa0f15003ec4e | Rust | muzudho/rust_kifuwarabe_igo2018 | /src/ren_db/piece_distribution_searcher.rs | UTF-8 | 4,151 | 3.234375 | 3 | [
"MIT"
] | permissive | // 連IDが入った盤を探索するやつだぜ☆(^~^)
use std::cmp;
use board::*;
use ren_db::ren_database::*;
// アプリケーション1つに、インスタンスは1個だけ存在するぜ☆(^~^)
pub struct PieceDistributionSearcher {
// 盤面を全クリアーする時間がもったいないから、マークの方を変えるぜ☆(^~^)
pub mark: i64,
pub mark_board: [i64; 21 * 21],
// 指定の連IDが入っているところだけを探す☆(^q^)
filter_ren: i16,
... | true |
fd43ae33c5b06a38c58f57c812cc4856ca3a894e | Rust | xnti/keci-mobile-api | /src/controller/user.rs | UTF-8 | 3,327 | 2.5625 | 3 | [
"MIT"
] | permissive | use crate::action;
use crate::action::user::{LoginResult, UserCreateResult};
use actix_web::{http, web, HttpRequest, HttpResponse, Responder};
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Debug, Clone)]
pub struct CreateUserBody {
pub phone: String,
password: String,
}
#[derive(Debug, Serialize, Des... | true |
874658082f407d966acad9608f6faf08c35a1eb0 | Rust | longyuan1996/rust-practice | /0001/random_number/src/main.rs | UTF-8 | 1,018 | 3.375 | 3 | [] | no_license | use rand::Rng;
use rand::distributions::{Distribution, Uniform};
fn run_random() {
let mut rng = rand::thread_rng();
let n1 : u8 = rng.gen();
let n2 : u16 = rng.gen();
// let n3 = rng.gen();
println!("Random u8: {}", n1);
println!("Random u16: {}", n2);
println!("Random u32: {}", rng.g... | true |
f536730d2fb8f39b6cec668e8436949271c1aba7 | Rust | FliegendeWurst/fend | /cli/src/config.rs | UTF-8 | 2,365 | 3 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::{env, fs, io, path};
#[derive(serde::Deserialize, serde::Serialize)]
pub struct Config {
pub prompt: String,
pub color: bool,
}
impl Default for Config {
fn default() -> Self {
Self {
prompt: "> ".to_string(),
color: false,
}
}
}
fn get_config_dir() ->... | true |
5e6ea0796ca7c1e7db807436b3a9f241d3438dcf | Rust | apache/incubator-teaclave-sgx-sdk | /sgx_tstd/src/net/socket_addr.rs | UTF-8 | 30,564 | 2.828125 | 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 |
5adaee953da3158aac79dd9281ce3097e36e99b0 | Rust | MoQuEs/RustTask | /src/functions.rs | UTF-8 | 1,173 | 2.875 | 3 | [
"MIT"
] | permissive | use chrono::{Date, Duration, TimeZone, Utc};
use crate::error::AppError;
pub fn room_type_with_meal(room_type: &str, meal: &str) -> String {
let mut str = String::with_capacity(2 + room_type.len() + meal.len());
str.push_str(room_type);
str.push(' ');
str.push_str(meal);
str
}
pub fn pax(adults... | true |
b08cff6183b6b90ae5076a76fb7e7ffefe47f71d | Rust | downtimes/aoc2017 | /day18/src/main.rs | UTF-8 | 5,130 | 3.0625 | 3 | [] | no_license | use std::io::{self, Read};
use std::sync::mpsc::{Sender, Receiver, channel};
use std::collections::HashMap;
use std::thread;
use std::time::Duration;
#[derive(Debug, Clone, Copy)]
struct Ridx(char);
#[derive(Debug, Clone, Copy)]
enum Operand {
Register(Ridx),
Constant(i64),
}
#[derive(Debug, Clone, Copy)]
e... | true |
eed3622bd4d8f8de7362e0c57d6b529e89fe9cbd | Rust | geoffreyporto/Rust-2 | /johnson.rs | UTF-8 | 3,823 | 3.078125 | 3 | [] | no_license | //rustc new.rs -A warnings
use std::io;
use std::cmp::Ordering;
use std::collections::BinaryHeap;
struct Johnson {
x: u32,
}
#[derive(Copy, Clone, Eq, PartialEq)]
struct que_node {
cost: u32,
vertex: u32,
}
impl Ord for que_node {
fn cmp(&self, other: &que_node) -> Ordering {
// Notice that... | true |
d20b740bd73940788c4c9a87d3b38505ed42752b | Rust | h4sh3d/mdbook-api | /src/api/engine.rs | UTF-8 | 6,935 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::api::parser::parser_from_str;
use crate::engine::Engine;
use pulldown_cmark::html;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use mdbook::book::BookItem;
use mdbook::errors::Result;
use mdbook::errors::ResultExt;
use mdbook::renderer::RenderContext;
use mdbook::utils;
#[derive(Se... | true |
15251223aec1ab4ba6c3bc566492850fb4ae4a75 | Rust | zackmdavis/Standard_Algorithms | /quicksort.rs | UTF-8 | 1,429 | 3.59375 | 4 | [] | no_license | fn swap (a: ~[int], p: int, q: int) -> ~[int] {
let mut b = a;
let temp = b[p];
b[p] = b[q];
b[q] = temp;
b
}
fn partition(a: ~[int], p: int, r: int) -> (int, ~[int]) {
let mut b = a;
let x: int = b[r];
let mut i: int = p-1;
for j in range(p, r) {
if b[j] <= x {
... | true |
34e3b46098ab51df0ee1b27bc08d9487fa1b2e7c | Rust | sbeckeriv/rust-algorithms | /chapter-2/template/src/pq.rs | UTF-8 | 574 | 3.328125 | 3 | [] | no_license | pub struct PQAlgo<'a, T: 'a> {
vec: &'a mut Vec<T>,
count: usize,
}
impl<'a, T: Ord> PQAlgo<'a, T> {
pub fn new(vec: &'a mut Vec<T>) -> Self {
PQAlgo {
vec: vec,
count: 0,
}
}
pub fn insert(&mut self, item: T) {
self.vec.push(item);
}
pub fn ma... | true |
676404d97fe08c915a1e8b670fa277ea5b0711c3 | Rust | matthewmichihara/advent-of-code | /2021/21/1.rs | UTF-8 | 1,574 | 3.140625 | 3 | [] | no_license | fn main() -> () {
println!("hello world");
let mut p1_score = 0;
let mut p2_score = 0;
let mut p1_pos = 8;
let mut p2_pos = 9;
let mut dice_value = 1;
let mut dice_rolls = 0;
loop {
let p1_roll_1 = dice_value;
let mut p1_roll_2 = (dice_value + 1) % 100;
if p1_roll_2 == 0 {
p1_roll_... | true |
0356f7b114d59a1b43545661a8d50732e14b2c30 | Rust | michaeldisaro/repo | /src/traits/metarepo_traits.rs | UTF-8 | 13,196 | 2.625 | 3 | [
"MIT"
] | permissive | use crate::models::structs::RepositoryItem;
use crate::services::n::*;
use crate::services::yarn::*;
use crate::traits::string_traits::StringExtension;
use semver::Version;
use std::collections::HashMap;
use std::fs;
use std::os::unix;
use std::path::PathBuf;
use std::process::Command;
pub trait MetarepoExtension {
... | true |
8985d7676e8be7590c8068eb08f61ef34b08ebd1 | Rust | eda3/rust_by_example | /src/bin/14-3-0_gen_trait.rs | UTF-8 | 1,347 | 3.609375 | 4 | [] | no_license | // コピー不可な型
// 訳注: `clone()`メソッドを用いないかぎり、値のコピーではなくムーブが起きる型
struct Empty;
struct Null;
// ジェネリック型 `T`に対するトレイト
trait DoubleDrop<T> {
// `self`に加えてもう一つジェネリック型を受け取り、
// 何もしないメソッドのシグネチャを定義
fn double_drop(self, _: T);
}
// `U`を`self`として、`T`をもう一つの引数として受け取る`DoubleDrop<T>`
// を実装する。`U`,`T`はいずれもジェネリック型
impl<T, U> DoubleDr... | true |
e35be2ed915e277c800e2ca7726be4c9b00abab4 | Rust | rust-rosetta/rust-rosetta | /tasks/hash-join/src/main.rs | UTF-8 | 1,623 | 3.859375 | 4 | [
"Unlicense"
] | permissive | use std::collections::HashMap;
use std::hash::Hash;
// If you know one of the tables is smaller, it is best to make it the second parameter.
fn hash_join<A, B, K>(first: &[(K, A)], second: &[(K, B)]) -> Vec<(A, K, B)>
where
K: Hash + Eq + Copy,
A: Copy,
B: Copy,
{
let mut hash_map = HashMap::new();
... | true |
3a7f25d1ee75e054fe5f9be2240a25099f5efe5d | Rust | ronin13/finde-rs | /src/main.rs | UTF-8 | 1,926 | 2.515625 | 3 | [
"MIT"
] | permissive | #![forbid(unsafe_code)]
mod constants;
mod crawler;
mod fileresource;
mod haslen;
mod indexer;
mod resource;
mod scheduler;
use anyhow::{anyhow, Result};
use log::info;
use log::Level;
use std::time::Instant;
use structopt::StructOpt;
use crawler::Crawler;
use fileresource::FileResource;
#[derive(Debug, StructOpt)]... | true |
bb655f8d46ec9bf732992b5f02ef2d1fb579be95 | Rust | TheBlueMatt/rust-lightning | /lightning-rapid-gossip-sync/src/error.rs | UTF-8 | 1,278 | 2.515625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use core::fmt::Debug;
use std::fmt::Formatter;
use lightning::ln::msgs::{DecodeError, LightningError};
/// All-encompassing standard error type that processing can return
pub enum GraphSyncError {
/// Error trying to read the update data, typically due to an erroneous data length indication
/// that is greater than ... | true |
d85794e39df14636a4890e73ba399676e85062ba | Rust | ZaoIsmael/football | /src/db/continents.rs | UTF-8 | 368 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use serde::{Deserialize};
#[derive(Deserialize)]
pub struct DbContinent{
pub id: u32,
pub name: String
}
static CONTINENTS_SOURCE: &str = include_str!("data/continents.json");
pub struct Continents {
continents: Vec<DbContinent>
}
impl Continents {
pub fn get() -> Vec<DbContinent> {
serde_js... | true |
513f1b12ed809ee401f9582cb5d271251c41cc43 | Rust | brson/fancy_flocks | /src/dirty_flock.rs | UTF-8 | 9,843 | 3.1875 | 3 | [] | no_license | /// A self-deleting flock that tracks whether a protected value needs
/// to be refreshed
use std::ops::DerefMut;
use std::io::{Seek, SeekFrom, Read, Write, Result, ErrorKind};
use std::fs::File;
use std::path::Path;
use std::cell::Cell;
use sd_flock::SdFlock;
use rand::random;
pub struct DirtyFlock(SdFlock, Cell<Epo... | true |
f14fe2bde093024501bec985c865ab8a333f1083 | Rust | luccasmmg/noodles | /noodles-bcf/src/writer.rs | UTF-8 | 5,860 | 2.625 | 3 | [
"MIT"
] | permissive | mod record;
mod string_map;
mod value;
use std::{
convert::TryFrom,
ffi::CString,
io::{self, Write},
};
use byteorder::{LittleEndian, WriteBytesExt};
use noodles_bgzf as bgzf;
use noodles_vcf as vcf;
use super::{header::StringMap, MAGIC_NUMBER};
const MAJOR: u8 = 2;
const MINOR: u8 = 2;
/// A BCF write... | true |
aebc34fed5f24cb33a8edf4f30f5aed9a5165d9b | Rust | MichaelWJung/chip8 | /src/keyboard.rs | UTF-8 | 2,684 | 3.203125 | 3 | [
"LicenseRef-scancode-public-domain",
"MIT"
] | permissive | use sdl2::EventPump;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
const KEY_0: Keycode = Keycode::Comma;
const KEY_1: Keycode = Keycode::Num7;
const KEY_2: Keycode = Keycode::Num8;
const KEY_3: Keycode = Keycode::Num9;
const KEY_4: Keycode = Keycode::H;
const KEY_5: Keycode = Keycode::G;
const KEY_6: Keycode =... | true |
b33ae5affcab129c55f35e4914d3077323b8d447 | Rust | gobanos/cargo-aoc | /examples/aoc-2018/day6.rs | UTF-8 | 3,981 | 3.171875 | 3 | [] | no_license | use aoc_runner_derive::{aoc, aoc_generator};
use fnv::FnvHashMap;
use fnv::FnvHashSet;
use std::error::Error;
use std::str::FromStr;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
struct Point {
x: u32,
y: u32,
}
impl Point {
fn distance(self, other: Point) -> u32 {
self.x.max(other.x) - self.x.min(... | true |
efa5a5c4238c3265238c489389b0e5f0d6636496 | Rust | Trark/magmaflow | /src/spv/logical/control_flow.rs | UTF-8 | 17,934 | 3.015625 | 3 | [
"MIT"
] | permissive |
use std::collections::HashMap;
use std::fmt;
use std::rc::Rc;
pub use super::super::types::*;
pub use super::super::op::*;
pub use super::*;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct BlockId(u32);
impl fmt::Display for BlockId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
... | true |
ab871945545caaaeac6b51385a68082b6b082f78 | Rust | ltearno/resolv | /runner.rs | UTF-8 | 2,970 | 2.734375 | 3 | [] | no_license | use crate::rule::*;
use crate::tools;
use std::collections::HashMap;
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};
pub fn run_for_rule<'a>(
rules: &'a Vec<Rule<'a>>,
to_build: &str,
rules_state_store: &mut HashMap<&'a str, u64>,
) {
let mut plan: Vec<&Rule> = Vec::new();
prin... | true |
308d404c0c8107ca570689bfeb96bade39ff0fdd | Rust | grodino/graphia | /src/models.rs | UTF-8 | 9,948 | 3.3125 | 3 | [
"MIT"
] | permissive | use std::convert::From;
use std::ops::Range;
use rand::{
prelude::*,
Rng,
distributions::weighted::alias_method::WeightedIndex,
};
use indicatif::{ProgressBar, ProgressStyle, ProgressIterator};
use crate::graph::{Contact, Graph};
/// Edge-Markovian graph model properties
pub struct EdgeMarkovian {
p... | true |
deef8ad1b8ef48dc75952bb1b7b196f89f10f49d | Rust | vedangj044/drogue-cloud | /database-common/src/models/diff.rs | UTF-8 | 4,635 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use serde_json::{Map, Value};
use std::collections::{HashMap, HashSet};
/// A database object we can diff.
pub trait Diffable {
fn labels(&self) -> &HashMap<String, String>;
fn annotations(&self) -> &HashMap<String, String>;
fn finalizers(&self) -> &Vec<String>;
fn data(&self) -> &Value;
}
/// A macro... | true |
18acf9c958f881ecdf35d0bb6c6d1a75824af792 | Rust | bartolsthoorn/simhash-rs | /src/lib.rs | UTF-8 | 3,831 | 3.359375 | 3 | [] | no_license | /**
Rust Simhash
Implemented by Bart Olsthoorn on 12/08/2014
Ported to Rust 1.16.0 by Jakub Pastuszek on 29/05/2017
With the help of http://matpalm.com/resemblance/simhash/
*/
use std::hash::{Hash, Hasher};
// Note: stdlib no longer exposes SipHasher directly
#[cfg(all(feature = "hasher-sip", not(feature = "hasher-fnv... | true |
5f2bba94e50c980e54fc2f698241a10b441d61a2 | Rust | tommilligan/reddit-linker-rs | /src/utils.rs | UTF-8 | 1,705 | 2.765625 | 3 | [] | no_license | use serenity::model::{
channel::{ChannelType, GuildChannel},
gateway::Presence,
guild::{GuildStatus, Member},
id::{ChannelId, UserId},
user::OnlineStatus,
};
use std::collections::HashMap;
pub fn get_num_guilds(guilds: &Vec<GuildStatus>) -> String {
if guilds.len() == 1 {
String::from("... | true |
db8dda88c9c9ad400db62cd27198e5bc5783a940 | Rust | knokko/knukki-rs | /src/component/render/drawn_region/mod.rs | UTF-8 | 4,516 | 3.546875 | 4 | [] | no_license | use crate::Point;
mod composite;
mod line_intersection;
mod oval;
mod rectangle;
mod transformed;
pub use composite::*;
pub use line_intersection::*;
pub use oval::*;
pub use rectangle::*;
pub use transformed::*;
/// Represents a part of the domain of a `Component` and is used to indicate in
/// which part of its do... | true |
e4ffc9327d8ee9a24c5c7c5c43ab69f5da71c1ec | Rust | seanmonstar/cookies | /tests/parse.rs | UTF-8 | 716 | 2.984375 | 3 | [] | no_license | use cookies::Cookie;
macro_rules! t {
(
$fn:ident: $src:expr,
$($method:ident = $value:expr,)+
) => (
#[test]
fn $fn() {
let cookie = cookies::parse($src).expect("parse");
// Check the getter methods
$(
assert_eq!(cookie.$method()... | true |
2940ed9328098b1b3cc357d04dedcbcc79c9a00e | Rust | tfrench15/exercism-solutions | /rust/allergies/src/lib.rs | UTF-8 | 1,983 | 3.625 | 4 | [] | no_license | #[derive(Clone)]
pub struct Allergies {
cause: Vec<Allergen>,
}
#[derive(Clone, Debug, PartialEq)]
pub enum Allergen {
Eggs,
Peanuts,
Shellfish,
Strawberries,
Tomatoes,
Chocolate,
Pollen,
Cats,
}
impl Allergies {
pub fn new(score: u32) -> Self {
if score == 0 {
... | true |
8e2ac8eb238807964dc0e2274b1fe3c0054d95b3 | Rust | TheNeikos/advent-of-code-2017 | /1/part2/src/main.rs | UTF-8 | 583 | 3.25 | 3 | [] | no_license | use std::io;
fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).expect("Reading line from stdin");
input = input.trim().into();
let mut repeat = input.chars().cycle().skip(input.len()/2);
let mut sum = 0;
for (cur, next) in input.chars().zip(repeat) {
let a ... | true |
d2919a2823e5e29ecaaf1d413b5feb2be2cf49a8 | Rust | zwhitchcox/leetcode_rs | /src/_1025_divisor_game.rs | UTF-8 | 221 | 3.0625 | 3 | [
"MIT"
] | permissive | struct Solution;
impl Solution {
fn divisor_game(n: i32) -> bool {
n % 2 == 0
}
}
#[test]
fn test() {
assert_eq!(Solution::divisor_game(2), true);
assert_eq!(Solution::divisor_game(3), false);
}
| true |
c01e9410327ead3270201ef5a602d2e6c5c204ee | Rust | MediaMatrix/perspective | /rust/perspective-viewer/src/rust/components/containers/dropdown.rs | UTF-8 | 3,734 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | ////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018, the Perspective Authors.
//
// This file is part of the Perspective library, distributed under the terms
// of the Apache License 2.0. The full license can be found in the LICENSE
// file.
use std::fmt::Debug;
u... | true |
feec0e74000af449125c32b8cbb75e6017b44729 | Rust | konstin/capybara | /capybara-derive/src/pyo3_builder.rs | UTF-8 | 5,460 | 2.640625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Beware, this code still includes some syn-0.11 artifacts
extern crate pyo3_derive_backend;
extern crate syn;
use super::BindingBuilder;
use proc_macro2::TokenStream;
pub struct Pyo3Builder;
/// This is the same boilerplate that pyo3 uses
impl BindingBuilder for Pyo3Builder {
fn class(&self, attr: TokenStream... | true |
cf2c74e98e01ebb801038e7b6956f07c4a9cca50 | Rust | yukimemi/rhq | /src/bin/rhq/ops/add.rs | UTF-8 | 1,111 | 2.78125 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use clap::{App, ArgMatches};
use rhq::Workspace;
use std::{env, path::PathBuf};
#[derive(Debug)]
pub struct AddCommand {
paths: Option<Vec<PathBuf>>,
verbose: bool,
}
impl AddCommand {
pub fn app<'a, 'b: 'a>(app: App<'a, 'b>) -> App<'a, 'b> {
app.about("Add existed repositories... | true |
ca1c45ceb4f039d3a7d97e835231351dec67685c | Rust | EFanZh/LeetCode | /src/problem_0630_course_schedule_iii/mod.rs | UTF-8 | 664 | 3.15625 | 3 | [] | no_license | pub mod binary_heap;
pub trait Solution {
fn schedule_course(courses: Vec<Vec<i32>>) -> i32;
}
#[cfg(test)]
mod tests {
use super::Solution;
pub fn run<S: Solution>() {
let test_cases = [
(&[[100, 200], [200, 1300], [1000, 1250], [2000, 3200]] as &[_], 3),
(&[[1, 2]], 1),
... | true |
390369dc28f61c90c449d04820925bde49f4794e | Rust | ods/rs-log-experiments | /build.rs | UTF-8 | 1,440 | 2.765625 | 3 | [] | no_license | use regex::Regex;
fn main() {
// The resulting format is `major.minor.patch[+N+hash][+dirty]`. The parts
// are:
// * release (major.minor.patch)
// * number of commits `N` on top of released version in development
// version with commit hash abbreviation `hash`
// * `dirty` marker f... | true |
78e45f710c0c8ea88dfc83aee3fcf7673a629c28 | Rust | IQ-SCM/widmann | /src/libwidmann/application/settings.rs | UTF-8 | 993 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::rt::io::net::ip::{SocketAddr, IpAddr, Ipv4Addr};
use knob::Settings;
pub trait SocketSettings {
fn socket(&self) -> SocketAddr;
fn port(&self) -> u16;
fn ip(&self) -> IpAddr;
}
impl SocketSettings for Settings {
fn socket(&self) -> SocketAddr {
do self.fetch_with("addr") |addr| {
match addr... | true |
e01a9d3c1a3f262e28474747c4c4baad18664f15 | Rust | hnorden/my-gatekeeper | /rust-service/src/main.rs | UTF-8 | 5,847 | 2.640625 | 3 | [
"MIT"
] | permissive | #![feature(proc_macro_hygiene, decl_macro)]
#![warn(rust_2018_idioms)]
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
#[macro_use]
extern crate serde_derive;
use rocket::http::Status;
use rocket::request::{self, FromRequest, Request};
use rocket::Outcome;
use rocket_contrib::json::{Json,... | true |
cfe9c0fe54bbda929a97d1662bef6b2c2a623e21 | Rust | LeJane/rust | /v1/src/front_models/chat_groups.rs | UTF-8 | 2,952 | 2.671875 | 3 | [] | no_license | use crate::front_models::users::FrontDisplayChatUser;
use crate::{deserialize_binary, utils::binary_read_helper::*, BinaryDecode, BinaryEncode};
use anyhow::Result;
use std::io::Cursor;
#[derive(Debug, Clone, Queryable)]
pub struct FrontDisplayChatGroup {
pub gid: i64,
pub group_name: String,
pub group_thu... | true |
7d7bffd1c830cf635394fad17c16f42a0daaae4f | Rust | cassandraoconnell/rustdown | /src/document/renderers/normal_element.rs | UTF-8 | 800 | 3.390625 | 3 | [] | no_license | use super::Render;
// [SPEC]: https://html.spec.whatwg.org/multipage/syntax.html#elements-2
pub struct NormalElement {
attributes: Vec<(String, String)>,
inner_text: String,
tag: String,
}
impl NormalElement {
pub fn new(tag: String, inner_text: String) -> NormalElement {
NormalElement {
... | true |
28039f088097207aec7c1c7617f24d00147d2eb7 | Rust | nickolay/git-interactive-rebase-tool | /src/git/src/repository.rs | UTF-8 | 9,285 | 2.890625 | 3 | [
"BSD-3-Clause",
"GPL-3.0-only",
"Apache-2.0",
"BSD-2-Clause",
"GPL-3.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later"
] | permissive | use std::{
path::{Path, PathBuf},
sync::Arc,
};
use git2::{Oid, Signature};
use parking_lot::Mutex;
use crate::{
commit_diff_loader::CommitDiffLoader,
errors::{GitError, RepositoryLoadKind},
Commit,
CommitDiff,
CommitDiffLoaderOptions,
Config,
Reference,
};
/// A light cloneable, simple wrapper around the `... | true |
ca6f06fd22e7cb3f83ec83a0de8abb3613d4eacb | Rust | eminence/procdump | /src/ui/widgets/task.rs | UTF-8 | 3,983 | 2.6875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::time::Instant;
use crossterm::event::KeyEvent;
use indexmap::IndexMap;
use procfs::{process::Process, ProcResult};
use tui::{
backend::Backend,
layout::Rect,
style::{Color, Style},
text::{Span, Spans, Text},
widgets::{Block, Borders, Paragraph},
Frame,
};
use crate::ui::{InputResult, ... | true |
b0cc961e0d485ea2a9572a33834afa02abe1c684 | Rust | debruinf/rewind | /src/main.rs | UTF-8 | 6,246 | 3.09375 | 3 | [] | no_license | extern crate clap;
use clap::{Arg, App, ArgMatches};
use std::fs;
use std::time::{Duration};
use std::path::Path;
use std::io::{stdin,stdout,Write};
struct Config {
time: Duration,
ask_confirmation: bool
}
// struct Ffile {
// modified: Duration,
// path: Path
// }
fn set_config(matches: ArgMatches ... | true |
8f6ad2236c95ec36b5307295a9fb3feb7ef5cb9e | Rust | fedtf/dataplotlib | /examples/simplexy.rs | UTF-8 | 565 | 2.734375 | 3 | [] | no_license | extern crate dataplotlib;
use dataplotlib::util::{linspace, zip2};
use dataplotlib::plotbuilder::PlotBuilder2D;
use dataplotlib::plotter::Plotter;
fn main() {
let x = linspace(0, 10, 100);
let y_sin = x.iter().map(|x| x.sin()).collect();
let xy_sin = zip2(&x, &y_sin);
let xy_lin = zip2(&x, &x);
... | true |
29b20ee5dc2aba1f563d7aa814a236a8f66d00a4 | Rust | novoru/simia | /src/builtins.rs | UTF-8 | 3,903 | 3.109375 | 3 | [] | no_license | use crate::ast::{ Ast };
use crate::object::{ Object, new_error };
fn len(args: Vec<Object>) -> Object {
if args.len() != 1 {
return new_error(format!("wrong number of arguments. got={}, want=1", args.len()));
}
match &args[0] {
Object::String { value } => return Object::Integer { value: v... | true |
3b498bed9f9f42b6545bef4e4e9dc03562688b90 | Rust | paritytech/parity-scale-codec | /src/encode_like.rs | UTF-8 | 5,562 | 3.25 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019 Parity Technologies
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... | true |
a40699a7362ddff5fa0ff68343d429e05910ef3b | Rust | doy/nbsh | /src/format.rs | UTF-8 | 1,891 | 2.828125 | 3 | [
"MIT"
] | permissive | use crate::prelude::*;
pub fn path(path: &std::path::Path) -> String {
let mut path = path.display().to_string();
if let Ok(home) = std::env::var("HOME") {
if path.starts_with(&home) {
path.replace_range(..home.len(), "~");
}
}
path
}
pub fn exit_status(status: std::process... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.